unidox Posted December 2, 2007 Share Posted December 2, 2007 How do I make it, so it only refreshes once, instead of every 5 sec looping. This is my code: var page = "incs/files.inc.php?p=admin_users"; 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, 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, true); req.send(); } } setTimeout("ajax(page,'up_users_res')", 5000); } 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; } } } Quote Link to comment Share on other sites More sharing options...
jaymc Posted December 2, 2007 Share Posted December 2, 2007 Take this out setTimeout("ajax(page,'up_users_res')", 5000); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.