<?PHP
header(
'content-type:text/html;charset=utf-8'
);
$op
=isset(
$_POST
[
'op'
])?
]:
''
;
if
(
==
'getdata'
){
$url
=
"http://market.huobi.com/staticmarket/detail.html"
;
$content
=
file_get_contents
);
str_replace
(
"view_detail("
,
"["
PHP plain" style="font-family:Monaco,
);
")"
"]"
);
echo
;
//$data=json_decode($content,true);
exit
;
}
?>
<divid=
"abc"
></div>
<scripttype=
"text/javascript"
src=
"http://code.jquery.com/jquery-latest.js"
></script>
<script>
setInterval(
"test()"
PHP plain" style="font-family:Monaco,2000);
function
test(){
$.ajax({
type:
"POST"
PHP plain" style="font-family:Monaco,
timeout:60000,
async:true,
data:
"op=getdata"
PHP plain" style="font-family:Monaco,
success:
(data,textStatus){
$(
"#abc"
).html(data);
}
});
}
</script>
|
1、将需要刷新的页面数据片段单独做出来
2、在原始页面中使用ajax轮询,每2秒请求一次,将请求得到的页面片段放入原始页面中对应的位置
3、调整完善页面样式
原文链接:https://www.f2er.com/ajax/161025.html