SitePoint Sponsor |
|
User Tag List
Results 1 to 1 of 1
Thread: Webpage refresh (AJAX) IMPORTANT
-
Apr 11, 2008, 06:57 #1
- Join Date
- Sep 2007
- Posts
- 971
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Webpage refresh (AJAX) IMPORTANT
Alot of people have been telling me for an auto refresh with no flicker on refresh in ie to use ajax i finally spent hours finding a code that worked and figured out the images still flicker on refresh, it dosnt output smoothly, what do i do to make it smooth refresh its for my chatroom:
Code:<head> <script type="text/javascript"> var page = "test2.php"; function ajax(url,target) { // native XMLHttpRequest object document.getElementById(target).innerHTML = ''; if (window.XMLHttpRequest) { req = new XMLHttpRequest(); req.onreadystatechange = function() {ajaxDone(target);}; req.open("GET", url+"?sid="+Math.random(), true); req.send(null); // IE/Windows ActiveX version } else if (window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); if (req) { req.onreadystatechange = function() {ajaxDone(target);}; req.open("GET", url+"?sid="+Math.random(), true); req.send(); } } setTimeout("ajax(page,'scriptoutput')", 2000); } function ajaxDone(target) { // only if req is "loaded" if (req.readyState == 4) { // only if "OK" if (req.status == 200 || req.status == 304) { results = req.responseText; document.getElementById(target).innerHTML = results; } else { document.getElementById(target).innerHTML="ajax error:\n" + req.statusText; } } } </script> </head> <body onload="ajax(page,'scriptoutput')"> <span id="scriptoutput"></span></p> </body>
Animated Chatrooms - www.121chatrooms.net
Bookmarks