0

I used the following function:

@Using Ajax.BeginForm("Index", New AjaxOptions() With { _
                                                        .UpdateTargetId = "AnswerSN",
                                                        .HttpMethod = "POST"
                                                      })
    @<Script>
         window.setInterval(function () {
             var updateUrl = '@Url.Action("ViewPoints", "Home")';
             $.get(updateUrl, function (result) {
                     initialize(result);
                 });
             }, 30000);

         </script>
    @<div id="AnswerSN" style="position:absolute; top:100px"></div>
End Using

Where to call every 30 seconds the "Viewpoints" controller "Home" icon. I returns every time a result of type json different from the previous one.

Ok , it works in all browsers but not in IE that processes the first time the "Viewpoints" and then processes every 30 seconds the same variable json (obviously returned to the first draft of the "Viewpoints").

How is this possible, if in other browsers I have my desired effect?

Many thanks to those who respond. dave

Dave
  • 93
  • 1
  • 10
  • possible duplicate of [Problem with IE and setInterval() not refreshing/updating](http://stackoverflow.com/questions/3426510/problem-with-ie-and-setinterval-not-refreshing-updating) – Raphaël Althaus Jan 08 '14 at 16:57

1 Answers1

3

GET requests cache, set the proper headers or set up jQuery to add the no cache parameter.

$.ajax({
  url: updateUrl,
  success: function(result){
    initialize(result);
  },
  cache: false
});

And it is not wise to use setInterval() with Ajax requests. They can stack up. Make sure to check if a previous request is open and abort it. You can use

timeout: 3000 
epascarello
  • 204,599
  • 20
  • 195
  • 236