<?php header( 'content-type:text/html;charset=utf-8' ); $op = isset( $_POST [ 'op' ]) ? $_POST [ 'op' ] : '' ; if ( $op == 'getdata' ) { $url = "http://market.huobi.com/staticmarket/detail.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= "abc" ></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=getdata" , success: function (data, textStatus) { $( "#abc" ).html(data); } }); } </script> |
1、将需要刷新的页面数据片段单独做出来
2、在原始页面中使用ajax轮询,每2秒请求一次,将请求得到的页面片段放入原始页面中对应的位置
3、调整完善页面样式