简体   繁体   中英

jquery / ajax - how to read a response from a jquery post() to a webservice

I'm trying to send data to a web service using jQuery's post() command - I'm getting a successful response back, I think, but I'm not sure what to use to refer to the data that is returned. Here's my code:

var insertResponse = $.post(
    "https://xxx.com/spark_submit.aspx", 
    { 
        NameFirst: "Joe", 
        NameLast: "Schmoe", 
        PostalCode: "11211", 
        EmailAddress: "joe@schmoe.com",
        Survey: "76:1139" 
    }, 
    function() {
        console.log(insertResponse);
    }).error(function() { 
        console.log("error"); 
    }
);

The insertResponse just returns a massive object including all data related to the processing of the response. I just want the XML that's returned. How can I retrieve it?

var insertResponse = $.post(
    "https://xxx.com/spark_submit.aspx", 
    { 
        NameFirst: "Joe", 
        NameLast: "Schmoe", 
        PostalCode: "11211", 
        EmailAddress: "joe@schmoe.com",
        Survey: "76:1139" 
    }, 
    function(data) {//data referes to the returned data from the service
        console.log(data);
        console.log(insertResponse);
    }).error(function() { 
        console.log("error"); 
    }
);

"The insertResponse just returns a massive object including all data related to the processing of the response. I just want the XML that's returned. How can I retrieve it?"

Does that object include a property that is the XML data though?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM