I have this code:
$.ajax({
type: "POST",
url: URL,
data: data,
dataType: 'jsonp',
crossDomain: true,
contentType: "application/json; charset=utf-8",
jsonpCallback: callback,
success: function (data,textStatus,jqXHR) {
alert("success");
},
error:function(jqXHR, textStatus, errorThrown){
alert(JSON.stringify(jqXHR));
},
complete: function(jqXHR, textStatus){
alert(JSON.stringify(jqXHR));
}
});
the the status response is 200 but it's treated as an error. I can see this on chrome response tab:
{
"error": "cannot create user because user already exists",
"code": 404
}
<-- this is the data returned by the server
and I can't get that data using jQuery.
I made it to work with this code:
$.ajax({
type: "POST",
url: URL,
data: data,
dataType: 'jsonp',
crossDomain: true,
contentType: "text/javascript",
success: function (data,textStatus,jqXHR) {
alert(JSON.stringify(data));
},
error:function(jqXHR, textStatus, errorThrown){
alert(JSON.stringify(jqXHR));
},
complete: function(jqXHR, textStatus){
alert(JSON.stringify(jqXHR));
}
});
hope this help.