【发布时间】:2015-09-15 12:51:44
【问题描述】:
我想中止另一个函数中的 Ajax 请求 示例:
var xhr = false;
$(function(e) {
$(document).on('click', '.menue-button', function(e) {
// Some JS
xhr = $.ajax({
type: "POST",
url: index.php,
//The ajax functions
});
});
});
$(document).on('click', '#progress-abort', function() {
xhr.abort();
});
调试器说:
Uncaught TypeError: Cannot read property 'abort' of undefined
我知道为什么,但我不知道如何解决问题
【问题讨论】: