[英]Why Can't I make recursive $http requests in IE 9 but I can in Firefox and Chrome
I have a function wrapping a $http request which on success calls the function again. 我有一个包装$ http请求的函数,成功后会再次调用该函数。 it works perfectly in Chrome and Firefox but in IE it doesn't make anymore requests after the initial Request, I have searched online and here on stack overflow but I cannot anyone with a similar issue or any solution 它在Chrome和Firefox中完美运行,但在IE中,它在发出初始请求后不再发出请求,我已经在网上搜索过,并且这里出现了堆栈溢出问题,但我不能遇到类似问题或解决方案的任何人
these are my functions: 这些是我的功能:
var poll = function () {
if (parseInt($scope.progress) < 100) {
temp = parseInt($scope.progress) + 1;
$scope.progressPolling();
}
}
$scope.progressPolling = function () {
alert("progressPolling " + i);
i++;
$http.get(url)
.success(function (data, status, headers, config) {
var percent = data.percentage;
alert("percent" + percentage);
if (parseInt($scope.progress) < 100) {
if (percent <= 100) {
$scope.progress = percent;
}
poll();
}
}).error(function (data, status, headers, config) {
alert("An Error Has Occured");
console.log("Error updating Progress: " + data);
});
the alert in the Success fires every time but with the same result as the initial requests result, It does not go to server, which I verified by putting a break point on the server side. “成功”中的警报每次都会触发,但其结果与初始请求结果相同,但不会发送到服务器,我通过在服务器端放置一个断点来验证了这一点。 The breaking point is hit once (the initial request) but not a 2nd time or with any subsequent requests. 中断点被击中一次(初始请求),但没有第二次击中,也没有后续任何击中。
as I said this only happens in IE (IE9 in my case) 正如我所说的,这仅在IE中发生(在我的情况下为IE9)
It is unfortunately required to support IE9 so I need to find a way to resolve this, a Hack would be better then nothing but I would Like to find the Issue and the correct approach to solving it, any advice would be greatly appreciated 不幸的是,需要支持IE9,因此我需要找到一种方法来解决此问题,Hack会比什么都没有更好,但我想找到问题以及解决问题的正确方法,我们将不胜感激任何建议
Thanks to Arun Killu and Chandermani Who pointed out it it may be caching the request Header. 感谢Arun Killu和Chandermani指出,这可能是在缓存请求标头。
I was able to solve it in 2 ways 我有两种方法可以解决
appending the date and time to the get request URL to make it unique 将日期和时间附加到获取请求URL上以使其唯一
$http.get(url+'?time='+new Date().toString())
using the meta tag: 使用meta标签:
<meta http-equiv="Pragma" content="no-cache">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.