0

我在 Actionscript 的 XMLList 中有值。需要将这些值发送到数据库并更新它。我的动作脚本代码如下:

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);                   

    }
  1. 如何将 XMLList 数据发送到 PHP?我应该添加一个 toString() 吗?
  2. Flex中的contentType也应该是什么。

我怎样才能在 PHP 中捕捉到这个,请告诉我,尝试使用这种方式,

if($user -> isAllowedAccess()) {

    header("Content-type:text/xml");
    $postedData =  $_POST["pdata"];     

   // $xmldoc = simplexml_load_string($POST['pdata']);
   // echo($xmldoc);

}

没运气。请让我知道。

4

1 回答 1

0

method属性HTTPService可能应该是“POST”,contentType请求本身的属性可能应该是“application/x-www-form-urlencoded”。

在 PHP 端,$_POST["pdata"]将是一个包含 XML 标记的字符串。您可以直接将其保存在数据库中,或者首先将其解析为 XML(通过SimpleXMLDOMDocument)并对包含的数据进行处理。

PS:我刚刚发现这个答案似乎对HTTPService班级的内部行为有所了解。

于 2010-05-25T11:44:56.557 回答