每隔一定时间执行一次ajax[异步刷新]
时间:2010-06-19 来源:hkebao
服务端只是数据提供,没有什么可写。主要是客户端的数据请求过程!
<body onload="javascript:setInterval('ajaxcheck()', 5000);">
This is my JSP page.<br>
<div id="uto"></div>
</body>
<script type="text/javascript">
function ajaxcheck() {
$.ajax({
type:"GET",
url: "/mytest/servlet/MyTest?number="+Math.random(),
dataType: 'json',
success:function(msg){
if(msg.flag=='1') {
$("#uto").html(msg.content);
}
}
})
}
</script>
这样就可以了。每隔一个时间执行一次
<body onload="javascript:setInterval('ajaxcheck()', 5000);">
This is my JSP page.<br>
<div id="uto"></div>
</body>
<script type="text/javascript">
function ajaxcheck() {
$.ajax({
type:"GET",
url: "/mytest/servlet/MyTest?number="+Math.random(),
dataType: 'json',
success:function(msg){
if(msg.flag=='1') {
$("#uto").html(msg.content);
}
}
})
}
</script>
这样就可以了。每隔一个时间执行一次
相关阅读 更多 +