ldbkutty
asked on
jQuery: "async: false" with "beforeSend"
Hi All,
The following code works good in Firefox, and displays the "Loading" image till there's a response. But the same does not show the "Loading" image in other browsers (IE, Safari).
I found somewhere that having both
async: false
and
beforeSend
doesn't go hand-in-hand. According to http://api.jquery.com/jQuery.ajax/#options : Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is active.
Is there any workaround? Please advise.
The following code works good in Firefox, and displays the "Loading" image till there's a response. But the same does not show the "Loading" image in other browsers (IE, Safari).
I found somewhere that having both
async: false
and
beforeSend
doesn't go hand-in-hand. According to http://api.jquery.com/jQuery.ajax/#options : Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is active.
Is there any workaround? Please advise.
var resp = $.ajax({
url: myUrl,
async: false,
beforeSend: function () {
jQuery('loading').show();
},
success: function(data, result) {
jQuery('loading').hide();
}
}).responseText;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Why not
jQuery('loading').show();
setTimeout(function(){
var resp = $.ajax({
url: myUrl,
async: false,
success: function(data, result) {
jQuery('loading').hide();
}
}).responseText;
},10);
Good question, I dono know. Perhaps to hide it double :)
ASKER
Thanks!