Guest User

Untitled

a guest
May 3rd, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. <html><head></head><body>
  2. <div id="feed"></div>
  3. <script type="text/javascript">
  4. var refreshtime=10;
  5. function tc()
  6. {
  7. asyncAjax("GET","myphpfile.php",Math.random(),display,{});
  8. setTimeout(tc,refreshtime);
  9. }
  10. function display(xhr,cdat)
  11. {
  12. if(xhr.readyState==4 && xhr.status==200)
  13. {
  14. document.getElementById("feed").innerHTML=xhr.responseText;
  15. }
  16. }
  17. function asyncAjax(method,url,qs,callback,callbackData)
  18. {
  19. var xmlhttp=new XMLHttpRequest();
  20. //xmlhttp.cdat=callbackData;
  21. if(method=="GET")
  22. {
  23. url+="?"+qs;
  24. }
  25. var cb=callback;
  26. callback=function()
  27. {
  28. var xhr=xmlhttp;
  29. //xhr.cdat=callbackData;
  30. var cdat2=callbackData;
  31. cb(xhr,cdat2);
  32. return;
  33. }
  34. xmlhttp.open(method,url,true);
  35. xmlhttp.onreadystatechange=callback;
  36. if(method=="POST"){
  37. xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  38. xmlhttp.send(qs);
  39. }
  40. else
  41. {
  42. xmlhttp.send(null);
  43. }
  44. }
  45. tc();
  46. </script>
  47. </body></html>
Add Comment
Please, Sign In to add comment