Jquery Ajax call not allowing other links to act normally
I have a page with many "normal" links (<a href=XXX>
) , part of this page is fetching data via jQuery Ajax method (this call might take around 20-30 seconds ...).
I've found out that if I press one of the links while the Ajax call is still running, I cannot redirect normally to the link's address and I have to wait till the Ajax call is finished (even though it's supposed to be asynchronous... isn't it?)
I guess I have to abort the Ajax call if any link is being pressed before it is finished - anyon开发者_StackOverflow中文版e can enlighten me how to do so?
Cheers,
If the links do not work, your ajax call should be synchronous. Synchronous (blocking) requests (async:false) lock your browser and prevent it from doing any action.
Check your code to see if you have passed a false async parameter to .ajax function. If you return the result of the .ajax call to a variable, you should have used a blocking request.
jQuery.ajax Example: Loads data synchronously. Blocks the browser while the requests is active. It is better to block user interaction by other means when synchronization is necessary.
var html = $.ajax({
url: "some.php",
async: false
}).responseText;
精彩评论