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

1

1 Answer 1

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 
Sign up to request clarification or add additional context in comments.

1 Comment

Nice explanation :) I didn't know there was a cache parameter available

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.