简体   繁体   English

为什么我不能在IE 9中进行递归$ http请求,但在Firefox和Chrome中却可以

[英]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 我有两种方法可以解决

  1. appending the date and time to the get request URL to make it unique 将日期和时间附加到获取请求URL上以使其唯一

    $http.get(url+'?time='+new Date().toString())

  2. using the meta tag: 使用meta标签:

    <meta http-equiv="Pragma" content="no-cache">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我的Ajax不能在Google Chrome或IE上运行,而在FireFox上运行,又如何使它工作? - Why Does my Ajax Not work on Google Chrome Or IE but works on FireFox, And how can i make it work 如何减少HTTP请求? - How can I Make fewer HTTP requests? 使用$ .getJSON(),我无法在任何版本的IE中接收结果。 Firefox / Chrome正常运行 - Using $.getJSON() I can't receive results in any version of IE. Firefox/Chrome work ok 我无法在Firefox中通过“ for”属性访问标签,但在Chrome中可以访问 - I can't access labels via “for” attribute in Firefox, but can in Chrome 为什么在nest.js中配置了控制器后不能拉HTTP请求 - why can't I pull HTTP requests after configured controller in nest.js google map api,chrome和firefox是正确的,但是不能运行 - google map api,chrome and firefox is right,but ie can't run 为什么我在Chrome中看不到我的HTTP标头? - Why can I not see my HTTP headers in Chrome? 如何使用TypeScript for IE11 / Edge / Chrome / Firefox编译Web组件? - How can I get Web Components to compile with TypeScript for IE11/Edge/Chrome/Firefox? 为什么我不能从递归函数返回? - Why can't I return from recursive function? 为什么我不能在Chrome中使用contentDocument来访问SVG文件,但是在Firefox中却可以呢? - Why can I not acces with contentDocument to a SVG file in Chrome but I can in Firefox?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM