将 xml 从 ActionScript 发送到 PHP
我在 Actionscript 的 XMLList 中有值。需要将这些值发送到数据库并更新它。 我的actionscript代码如下:
public static function saveUserPermList():void {
var ht:HTTPService = new HTTPService();
ht.url = Config.getServerURL();
ht.method = URLRequestMethod.POST;
//ht.resultFormat = "e4x";
ht.contentType = "text/xml";
ht.request["action"] = "saveUserPermListXML";
ht.request["pdata"] = Application.application.userPermListModel.toString();
ht.addEventListener(ResultEvent.RESULT,AdminUserList.saveUserPermListResult);
ht.send();
}
public static function saveUserPermListResult(e:ResultEvent):void {
trace(e);
}
- 如何将XMLList数据发送到PHP?我应该添加一个 toString() 到它吗?
- Flex 中的 contentType 应该是什么?
我怎样才能在 PHP 中捕获这个,请告诉我,尝试使用这种方式,
if($user -> isAllowedAccess()) {
header("Content-type:text/xml");
$postedData = $_POST["pdata"];
// $xmldoc = simplexml_load_string($POST['pdata']);
// echo($xmldoc);
}
不走运。请告诉我。
I have values inside an XMLList in Actionscript. Need to send these values to the DB and update it.
My actionscript code is as follows:
public static function saveUserPermList():void {
var ht:HTTPService = new HTTPService();
ht.url = Config.getServerURL();
ht.method = URLRequestMethod.POST;
//ht.resultFormat = "e4x";
ht.contentType = "text/xml";
ht.request["action"] = "saveUserPermListXML";
ht.request["pdata"] = Application.application.userPermListModel.toString();
ht.addEventListener(ResultEvent.RESULT,AdminUserList.saveUserPermListResult);
ht.send();
}
public static function saveUserPermListResult(e:ResultEvent):void {
trace(e);
}
- How can I send the XMLList data to PHP? Should I add a toString() to it?
- Also what should be the contentType in Flex.
How can I catch this inside PHP, pl let me know, trying to use, this way,
if($user -> isAllowedAccess()) {
header("Content-type:text/xml");
$postedData = $_POST["pdata"];
// $xmldoc = simplexml_load_string($POST['pdata']);
// echo($xmldoc);
}
No luck. Pl let me know.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
HTTPService
的method
属性可能应该是“POST”,请求本身的contentType
可能应该是“application/x-www-形式 urlencoded”。在 PHP 端,
$_POST["pdata"]
将是一个包含 XML 标记的字符串。您可以直接将其保存在数据库中,或者首先将其解析为 XML(通过SimpleXML
或DOMDocument
),然后对包含的数据执行某些操作。PS:我刚刚发现 这个答案似乎揭示了
HTTPService
类的内部行为。The
method
property ofHTTPService
should probably be "POST", and thecontentType
for the request itself should probably be "application/x-www-form-urlencoded".On the PHP side,
$_POST["pdata"]
would then be a string containing XML markup. You could either save that in a database directly, or first parse it into XML (viaSimpleXML
orDOMDocument
) and do something with the contained data.PS: I've just found this answer that seems to shed some light on the internal behavior of the
HTTPService
class.