var xmlhttp=false;//creates a Boolean variable to detect if it is a legitimate instance of IE
try{//Detect if you are using IE
Xmlhttp=new actionxobject (' msxml2.xmlhttp ');//If JS version is greater than 5
}catch (e) {//If not, use the old version of the ActionX object
try{
Xmlhttp=new actionxobject ("microslft.xmlhttp");//If you are using IE browser
}catch (E2) {}
}
If you are using a non-IE browser, create a JS instance of the object
if (!xmlhttp && typeof xmlhttprequest!= "undefined") {
try{
Xmlhttp=new XMLHttpRequest ();
}catch (E3) {
Xmlhttp=false;
}
}
Timer=window.setinterval ("ShowTime ()", 1000);//Call ShowTime function once every second
Define the Showtime function to read data from a showtime.php file through a XMLHttpRequest object
function ShowTime () {
Xmlhttp.open ("Post", "showtime.php", true);//Send a new request with the Post method
Xmlhttp.onreadystatechange=function () {
if (xmlhttp.readystate==4) {//If the server responds to a request, do the following
Tet=xmlhttp.responsetext; Gets the response information returned
Gets the information given to the DIV tag
document.getElementById ("Show_time"). Innerhtml=tet;
}
}
Xmlhttp.send (NULL); Send Request
}
Timer=window.setinterval ("Sparetime ()", 1000);//Call sparetime function once every second
Define the Sparetime function to read data from a sparetime.php file through a XMLHttpRequest object
function Sparetime () {
Xmlhttp.open ("Post", "sparetime.php", true);//Send a new request with the Post method
Xmlhttp.onreadystatechange=function () {
if (xmlhttp.readystate==4) {//If the server responds to a request, do the following
Tet=xmlhttp.responsetext; Gets the response information returned
Gets the information given to the DIV tag
document.getElementById ("Sparetime"). innerhtml=tet;//when the remaining time is 00:00
if (tet== "00:00") {//Submit data in Form1 form
Form1.submit ();
}
}
}
Xmlhttp.send (NULL); Send Request
}
Ajax No Refresh