Asp.net MVC page refresh sing AJAX

1.2k views Asked by At

I am working on asp.net MVC , here i have used highcharts that will display data coming from a meter. Data is coming after every 15-20 seconds so i want to reload/refresh the page after every 15/20 seconds using ajax.

How can i accomplish this ?

This is my url Home/MultiGraph

Any help would be highly appreciated.

1

There are 1 answers

2
Robin Halder On

Simply use this if you want automatic page refresh

<meta http-equiv="refresh" content="5" >

where content = "5" is the waiting time that is 5 seconds. It will refresh your page after 5 seconds.

Or,try this.

<html>
<head>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <title>Ajax Page</title>
    <script>
    setInterval(function () { autoloadpage(); }, 30000); // it will call the function autoload() after each 30 seconds. 
    function autoloadpage() {
        $.ajax({
            url: "URL of the destination page",
            type: "POST",
            success: function(data) {
                $("div#wrapper").html(data); // here the wrapper is main div
            }
        });
    }
    </script>
</head>
<body>
<div id="wrapper">
contents will be changed automatically. 
</div>

Another shot to try, Just insert this code anywhere in the page:

<script type="text/javascript">
  setTimeout(function(){
  location = ''
 },60000)
</script>