views:

32

answers:

1

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

    }
  1. How can I send the XMLList data to PHP? Should I add a toString() to it?
  2. 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.

A: 

The method property of HTTPService should probably be "POST", and the contentType 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 (via SimpleXML or DOMDocument) 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.

Tomalak
Content type as "application/x-www-form-urlencoded" is not working. Just want to know how to send a xml string from Actionscript to PHP.The collection used in the code is XMLList.
Vish
@Vish: Have you tried installing a network sniffer and looking at the packets that go over the wire? Maybe that's the first step to debug the problem.
Tomalak
Hi Tomalak, Thanks for the tips, actually tried another option. Split the XMLList to create a string and then sent the string to PHP. In the PHP, used the explode function to get the contents. Works fine.Thanks again.
Vish