mheavers
mheavers

Reputation: 30158

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: "[email protected]",
        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?

Upvotes: 2

Views: 2286

Answers (2)

maxedison
maxedison

Reputation: 17553

"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?

Upvotes: 0

Rafay
Rafay

Reputation: 31033

var insertResponse = $.post(
    "https://xxx.com/spark_submit.aspx", 
    { 
        NameFirst: "Joe", 
        NameLast: "Schmoe", 
        PostalCode: "11211", 
        EmailAddress: "[email protected]",
        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"); 
    }
);

Upvotes: 1

Related Questions