1. #1
    Sencha User
    Join Date
    Jul 2011
    Location
    Ohio
    Posts
    13
    Vote Rating
    0
    MaximusW is on a distinguished road

      0  

    Default Ajax Request: Parsing the Response Object

    Ajax Request: Parsing the Response Object


    I'm calling a web service using the following Ext.Ajax.request:

    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);
         }
    })
    The success outputs the following:
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <int xmlns="http://mywebservicesite.com/survey.asmx">490</int>
    So my question is how do I grab the value "490" from the response.responseText.

  2. #2
    Sencha User
    Join Date
    Jul 2011
    Location
    Ohio
    Posts
    13
    Vote Rating
    0
    MaximusW is on a distinguished road

      0  

    Default 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:
    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);
    I hope this may prove useful for newbies (like me).

  3. #3
    Sencha User
    Join Date
    Jul 2010
    Location
    Switzerland
    Posts
    78
    Vote Rating
    0
    fx-mike is on a distinguished road

      0  

    Default


    You could use Ext.DomQuery, here is an example
    Code:
    Ext.DomQuery.selectNode('int', response.responseXML).textContent

  4. #4
    Sencha User
    Join Date
    Jul 2011
    Location
    Ohio
    Posts
    13
    Vote Rating
    0
    MaximusW is on a distinguished road

      0  

    Default


    Quote Originally Posted by fx-mike View Post
    You could use Ext.DomQuery, here is an example
    Code:
    Ext.DomQuery.selectNode('int', response.responseXML).textContent
    That's exactly what I was looking for. Anytime you can reduce 5 lines of code to 1 line of code it's a good thing.
    Thank you, fx-mike.

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar