Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html><head></head><body>
- <div id="feed"></div>
- <script type="text/javascript">
- var refreshtime=10;
- function tc()
- {
- asyncAjax("GET","myphpfile.php",Math.random(),display,{});
- setTimeout(tc,refreshtime);
- }
- function display(xhr,cdat)
- {
- if(xhr.readyState==4 && xhr.status==200)
- {
- document.getElementById("feed").innerHTML=xhr.responseText;
- }
- }
- function asyncAjax(method,url,qs,callback,callbackData)
- {
- var xmlhttp=new XMLHttpRequest();
- //xmlhttp.cdat=callbackData;
- if(method=="GET")
- {
- url+="?"+qs;
- }
- var cb=callback;
- callback=function()
- {
- var xhr=xmlhttp;
- //xhr.cdat=callbackData;
- var cdat2=callbackData;
- cb(xhr,cdat2);
- return;
- }
- xmlhttp.open(method,url,true);
- xmlhttp.onreadystatechange=callback;
- if(method=="POST"){
- xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
- xmlhttp.send(qs);
- }
- else
- {
- xmlhttp.send(null);
- }
- }
- tc();
- </script>
- </body></html>
Add Comment
Please, Sign In to add comment