$php_mysql$ Posted September 25, 2011 Share Posted September 25, 2011 i wish to add an loading image before the random.php displays content, how to do it? <script type="text/javascript"> function getHTTPObject(){ if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP"); else if (window.XMLHttpRequest) return new XMLHttpRequest(); else { alert("Your browser does not support AJAX."); return null; } } var inc=0; function callPHP(){ httpObject = getHTTPObject(); if (httpObject != null) { httpObject.open("GET", "http://localhost/script/random.php", true); httpObject.send(null); httpObject.onreadystatechange = setDiv; } setTimeout("callPHP()", 5000); } function setDiv(){ if(httpObject.readyState == 4){ document.getElementById('oPut').innerHTML = httpObject.responseText; } } window.onload=callPHP; </script> Quote Link to comment Share on other sites More sharing options...
Sajesh Mohan Posted September 26, 2011 Share Posted September 26, 2011 function setDiv(){ if(httpObject.readyState == 4){ document.getElementById('oPut').innerHTML = httpObject.responseText; } else { document.getElementById("oPut").innerHTML="<img src=\"images/003.gif\" height=\"20\" width=\"20\" />"; } } window.onload=callPHP; try it Quote Link to comment Share on other sites More sharing options...
$php_mysql$ Posted September 29, 2011 Author Share Posted September 29, 2011 hi thanks i actually have tried that before but nothing showed 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.