Abort a previous running Ajax request

This question already has an answer here:

  • Abort Ajax requests using jQuery 18 answers

  • 尝试这样的事情

            $(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 );
                        }
                    });
                }
            });
    
    链接地址: http://www.djcxy.com/p/71932.html

    上一篇: 我如何中止AJAX呼叫?

    下一篇: 中止以前运行的Ajax请求