My problem here is that my main page loads some slow asp pages into my divs through jQuery:
$("#content").load("really_slow.asp");
But if I try to go to another page on my site by clicking a link before the ASP page is done, it won't let me go until it's finished loading.
I've tried several ways, but nothing appears to work.... I tried something like this:
var request = $.ajax({
type: 'GET',
url: 'really_slow.asp',
success: function(result){
$("#content").html(result);
}
});
$("a").click(function() {
request.abort();
});
with no difference...
You're almost there, just one critical mistake in your code. It should be:
var request = $.ajax({
type: 'GET',
url: 'really_slow.asp',
success: function(result){
$("#content").html(result);
}
});
$("a").click(function() {
request.abort();
});
The abort()
method should be called on the jqXHR
object, not the #content
div.
See: Abort Ajax requests using jQuery
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With