-
18 Aug 2011 6:42 AM #1
Ajax Request: Parsing the Response Object
Ajax Request: Parsing the Response Object
I'm calling a web service using the following Ext.Ajax.request:
The success outputs the following:Code:Ext.Ajax.request({ params: {CustomerNumber:customerNumber, SurveyID:surveyId}, url: 'http://mywebservicesite.com/survey.asmx/surveyInfo', success: function(response) { console.log(response.responseText); }, error: function(msg) { console.log("Error: " + msg); } })
So my question is how do I grab the value "490" from the response.responseText.Code:<?xml version="1.0" encoding="utf-8"?> <int xmlns="http://mywebservicesite.com/survey.asmx">490</int>
-
18 Aug 2011 11:08 AM #2
Unless there's an easier way...
Unless there's an easier way...
I don't know if this is the best/easiest solution, but here's what I'm using:
I hope this may prove useful for newbies (like me).Code:parser=new DOMParser(); xmlDoc=parser.parseFromString(response.responseText, "text/xml"); x=xmlDoc.getElementsByTagName("int")[0]; y=x.childNodes[0]; console.log("Success: " + y.nodeValue);
-
19 Aug 2011 1:17 AM #3
You could use Ext.DomQuery, here is an example
Code:Ext.DomQuery.selectNode('int', response.responseXML).textContent
-
19 Aug 2011 3:54 AM #4


Reply With Quote