【发布时间】:2018-03-30 20:19:18
【问题描述】:
以下解决方案对我不起作用
How to cancel an $http request in AngularJS?
上面的解决方案效果-也中止新的ajax调用,应该是允许新的ajax调用和中止旧的ajax调用
我的代码
$scope.callajax = function () {
var canceller = $q.defer();
var data = {};
data['id'] = id;
$http({
method: "post",
url: url,
data: $.param(data),
timeout: canceller.promise,
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}).success(function (response) {
});
canceller.resolve();
};
我正在调用这个函数,如果我一次调用这个函数两次,那么它应该中止第一个 ajax 调用并触发新的 ajax 调用
【问题讨论】: