0

I have a function wrapping a $http request which on success calls the function again. 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

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)

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

4

1 回答 1

1

感谢 Arun Killu 和 Chandermani 指出它可能正在缓存请求标头。

我能够通过两种方式解决它

  1. 将日期和时间附加到获取请求 URL 以使其唯一

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

  2. 使用元标记:

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

于 2013-09-18T13:13:10.750 回答