ferd tomale
ferd tomale

Reputation: 903

How do I retrieve the responseText of a jquery.ajax error?

The code goes like this:

$.ajax({
    url: "http://server.com/rest",
    dataType: "jsonp",
    success:function(d, t, x) {
        console.log(d);
    },
    error:function(x, t, e) {
        console.log(x.responseText);
    }
});

Firebug shows that I am receiving a response but the code above only logs "undefined". Firebug also shows that the http status code is 200. Can anybody tell me how to retrieve the response?

Upvotes: 0

Views: 114

Answers (1)

Anoop Joshi P
Anoop Joshi P

Reputation: 25527

if you are using jsonp. your server should bind the response to a callback function. Example

server response

myFunction(someresponsehere)

client side

function myFunction(response)
{
  //you will get the response from server here "response"
  }

Upvotes: 1

Related Questions