I have a question here. Let's say I have some Ajax with jQuery like so:
var jqXHR = $.ajax({
type: 'POST',
success: function(data) {
if(data != true)
{
return false;
}
}
});
I know that $.ajax returns a jqXHR object. My question is the following:
Is it possible to get the returned value of the success function of my $.ajax call using that jqXHR object? If so, how do I do that? If that's not possible using the jqXHR object, is there any way that I can get access to the returned value of my success function WITHOUT SETTING async: false in $.ajax?
Any help please?
It is not possible without setting
async
tofalse
. I would suggest not to set it to false because it stops the page completely until the server response comes. Sometimes it even hangs the browser if the connection is slow or server takes time to respond due to heave operation.You can execute your code in the success handler of
ajax
which you are planning to do it outside.