![](/img/trans.png)
[英]ASP.NET MVC 3 - After ajax call, redirect to new page or generate page refresh
[英]Asp.net MVC page refresh sing AJAX
我正在asp.net MVC上工作,在这里我使用了将显示来自仪表的数据的图表。 数据每隔15-20秒就会到来,所以我想每15/20秒后就使用ajax重新加载/刷新页面。
我怎样才能做到这一点?
这是我的url
Home/MultiGraph
任何帮助将不胜感激。
如果您要自动刷新页面,只需使用它
<meta http-equiv="refresh" content="5" >
其中content =“ 5”是5秒的等待时间。 5秒钟后它将刷新您的页面。
或者,尝试一下。
<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>
可以尝试的另一种方法,只需将此代码插入页面中的任何位置:
<script type="text/javascript">
setTimeout(function(){
location = ''
},60000)
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.