[英]Asp.net MVC page refresh sing AJAX
I am working on asp.net MVC , here i have used highcharts that will display data coming from a meter . 我正在asp.net MVC上工作,在这里我使用了将显示来自仪表的数据的图表。 Data is coming after every 15-20 seconds so i want to reload/refresh the page after every 15/20 seconds using ajax.
数据每隔15-20秒就会到来,所以我想每15/20秒后就使用ajax重新加载/刷新页面。
How can i accomplish this ? 我怎样才能做到这一点?
This is my url
Home/MultiGraph
这是我的
url
Home/MultiGraph
Any help would be highly appreciated. 任何帮助将不胜感激。
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. 其中content =“ 5”是5秒的等待时间。 It will refresh your page after 5 seconds.
5秒钟后它将刷新您的页面。
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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.