中止以前运行的Ajax请求

是否可以中止以前运行的Ajax请求?

var xhr = $.ajax({ type: "POST", url: "some.php", data: "name=John&location=Boston", success: function(msg){ alert( "Data Saved: " + msg ); } }); 

尝试这样的事情

  $(document).ready(function(){ var xhr; // global object function your_function() { if(xhr && xhr.readystate != 4){ xhr.abort(); } xhr = $.ajax({ type: "POST", url: "some.php", data: "name=John&location=Boston", success: function(msg){ alert( "Data Saved: " + msg ); } }); } });