I have a simple AJAX call that is executing a function on the beforeSend
and on complete
. They execute fine but the beforeSend
is "seemingly" not executed until after the success.
On the beforeSend
there is a "Please wait" notification. If I put a break after the function in the beforeSend
then it will show that notification and then hit the success. Without the break point then it will sit there and think while waiting for the response and then my please wait notification will appear for a fraction of a second after the success is hit.
The desired functionality is to have the notification appear as soon as the request is sent so it displays while it is waiting for the response.
$.ajax({
type : 'POST',
url : url,
async : false,
data : postData,
beforeSend : function (){
$.blockUI({
fadeIn : 0,
fadeOut : 0,
showOverlay : false
});
},
success : function (returnData) {
//stuff
},
error : function (xhr, textStatus, errorThrown) {
//other stuff
},
complete : function (){
$.unblockUI();
}
});
async=false
? – FardbeforeSend
doesn't make any sense in combination withasync:false
. If you want to keepasync:false
, you can just add theblockUI
call before yourajax(...)
, since the code will be executed synchronously anyway. – EnmeshblockUI
call is still being executed after thesuccess
handler? – Enmesh