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