Entire page Refresh
1. Automatic page refresh: Add the following code to the
20 refers to a refresh of the page every 20 seconds.
2. Page Auto-jump: Add the following code to the
Where 20 means jump to # page after 20 seconds
3. Page automatically refresh JS version
How jquery implements Div timed refreshes
1 <Head>2 3 <Scriptsrc= "Jquery/jquery-1.4.1.min.js"type= "Text/javascript"></Script>4 5 <Script>6 $ (document). Ready (function () {7 8 SetInterval ("startrequest ()", +);9 //SetInterval This function executes the previous function every 1 seconds according to the 1000 defined laterTen //If you use local refresh, use AJAX technology One }); A - functionstartrequest () - { the $("#date"). Text (NewDate ()). ToString ()); - } - </Script> - + </Head>
Ajax Local Refresh
Ajax Local timed Refresh
1 <!DOCTYPE HTML>2 <HTMLLang= "ZH-CN">3 <Head>4 <MetaCharSet= "Utf-8">5 <title>Ajax Auto Local timed Refresh</title>6 <Scripttype= "Text/javascript"src= "Jquery-1.11.2.js"></Script>7 </Head>8 <Body>9 <Script>Ten $ (document). Ready (function(){ One SetInterval ("Change ()", +) A }) - functionChange () { - $.ajax ({ the URL:"demo1.php", - Cache:false, - DataType:"JSON", - Success:function(data) { + $("#aa"). HTML (data); - } + }) A } at </Script> - <DivID= "AA"></Div> - </Body> - </HTML>
Ajax Local Manual Refresh
1 <!DOCTYPE HTML>2 <HTMLLang= "ZH-CN">3 <Head>4 <MetaCharSet= "Utf-8">5 <title>Ajax Manual Local Refresh</title>6 <Scripttype= "Text/javascript"src= "Jquery-1.11.2.js"></Script>7 </Head>8 <Body>9 <Script>Ten functionChange () { One $.ajax ({ A URL:"demo1.php", - Cache:false, - DataType:"JSON", the Success:function(data) { - $("#aa"). HTML (data); - } - }) + } - </Script> + <DivID= "AA"></Div> A <Buttononclick= "Change ()">Manual Refresh button</Button> at </Body> - </HTML>
The demo1.php tested are as follows:
1<?PHP2 Header("Content-type:text ml; Charset=utf-8 " );3 4 $oldnum=file_get_contents("C:\111.txt");5 $oldnum=$oldnum+1; 6 file_put_contents("C:\111.txt",$oldnum);7 8 Echo $oldnum;9?>
Page refreshes the entire page refresh and local refresh