Automatic reloading of HTML part without reloading the complete page

function getXMLHTTPRequest() { var req = false; try { /* for Firefox */ req = new XMLHttpRequest(); } catch (err) { try { /* for some versions of IE */ req = new ActiveXObject("Msxml2.XMLHTTP"); } catch (err) { try { /* for some other versions of IE */ req = new ActiveXObject("Microsoft.XMLHTTP"); } catch (err) { req = false; } } } return req; } function getServerTime() { var thePage = 'servertime.php';//A file which will be load // myRand = parseInt(Math.random()*999999999999999); // var theURL = thePage +"?rand="+myRand; myReq.open("GET", thePage, true); myReq.onreadystatechange = theHTTPResponse; myReq.send(null); } function theHTTPResponse() { if (myReq.readyState == 4) { if(myReq.status == 200) { document.getElementById('content').innerHTML = myReq.responseText; } } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.