I make a request to a server with JQuery and the $.when method.
$.when(ajaxRequest(param)).done(function(response){
console.log(responseData);
});
my ajax function looks like this:
function ajaxRequest(param){
var requestedData;
return $.ajax({
type: 'POST',
url: myurl,
data: {
setParam:param
},
error: function(data){
console.log(data);
return(data);
}
});
}
Everything works fine if the server returns a 200 OK. But if there was something wrong the server answers with 500. How can I return the response body to the calling method?
The errorbody is printed with console.log on the ajaxRequest method but its not returned to the calling method?