0

I am using worklight adapter as http adapter and i am htting on url and getting plain text from result now how to use it on client side. I am getting xml as a plian text now i want to use that xml on client side tell me how to do that.

function searchData(){

    var input = {
            method : 'post',
            //requestType : 'http',
            path : 'Mobile/Default.aspx',
            returnedContentType : 'plain',
             body : {
                    contentType: 'application/x-www-form-urlencoded',
                    acceptEncoding: 'gzip',
                    content: 'xml=<HOME><REQUEST><USERID>5345435</USERID></HOME>'


                }
            };


    return WL.Server.invokeHttp(input);

}  
{
   "errors": [
   ],
   "info": [
   ],
   "isSuccessful": true,
   "responseHeaders": {
      "Cache-Control": "private",
      "Content-Length": "42263",
      "Content-Type": "text\/xml; charset=utf-8",
      "Date": "Mon, 19 Nov 2012 07:03:46 GMT",
      "Server": "Microsoft-IIS\/6.0",
      "X-AspNet-Version": "2.0.50727",
      "X-Powered-By": "ASP.NET"
   },
   "statusCode": 200,
   "statusReason": "OK",
   "text": "<HOME><REQUEST><USERID>5345<\/USERID><SECURE_KEY>fsdfs<\/SECURE_KEY><DEVICE_ID>e52164cc6cce6a39<\/DEVICE_ID></HOME>"  

I want to use that text output in my client side function how to do that

Dilberted
  • 1,172
  • 10
  • 23

1 Answers1

1

Set returnedContentType to "xml". This way adapter will automatically convert your XML to JSON.

You can the reference it as response.HOME.REQUEST.USERID and/or return it to application.

Anton
  • 3,166
  • 1
  • 13
  • 12