Skip to content

Instantly share code, notes, and snippets.

@rainyjune
Created November 16, 2012 06:50
Show Gist options
  • Save rainyjune/4084898 to your computer and use it in GitHub Desktop.
Save rainyjune/4084898 to your computer and use it in GitHub Desktop.
cancel/abort jquery ajax request
$(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