Created
November 16, 2012 06:50
-
-
Save rainyjune/4084898 to your computer and use it in GitHub Desktop.
cancel/abort jquery ajax request
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready( | |
var xhr; | |
var fn = function(){ | |
if(xhr && xhr.readyState != 4){ | |
xhr.abort(); | |
} | |
xhr = $.ajax({ | |
url: 'ajax/progress.ftl', | |
success: function(data) { | |
//do something | |
} | |
}); | |
}; | |
var interval = setInterval(fn, 500); | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment