0

This is my JavaScript code:

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">

function mytest() {

        var jqxhr = $.get("Home/GetMonitorData", function (data) {
        $("#cpu").text(data.cpu);
        $("#dspace").text(data.dspace);
        $("#cspace").text(data.cspace);
        $("#pf").text(data.pf);
        $("#totphysical").text(data.totphysical);
        $("#freephysical").text(data.freephysical);
        $("#tcp").text(data.tcp);
        $("#req").text(data.req);


    }, "json");

}

$(document).ready(function () {
    setInterval(mytest, 3000);
}); 



</script> 

The issue is, setInterval only runs once. My program is supposed to get some WMI Information from an action method, print in on screen, and refresh these values every 3 seconds. But after one refresh, it stops. Any suggestions/ideas?

Slethron
  • 143
  • 1
  • 4
  • 11
  • 2
    I find when setInterval fails to continually run, it's due to a javascript error in the timer function (at least, that's what FireFox does). Have you checked the javascript error log? – Nick Shaw Aug 17 '11 at 08:56

2 Answers2

2

You need to set Request.Expires = 0 when calling ajax.

ogzd
  • 36
  • 1
0

Maybe ajax requests stack because there is no time and then break the chain?

Try increasing the interval size for debugging purposes and see if the situation has changed.

Nemanja
  • 1,505
  • 12
  • 24