All pastes #822249 Raw Edit

Yancho

public javascript v1 · immutable
·published 2007-12-18 16:53 UTC
rendered paste body
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title><script language="javascript" type="text/javascript">function ajaxFunction(){	//create an XMLHttp object	var http_request = false;	   if (window.XMLHttpRequest)    { // Mozilla, Safari,...       http_request = new XMLHttpRequest();       if (http_request.overrideMimeType) {           http_request.overrideMimeType('text/html');   		}   }    else if (window.ActiveXObject)    { // IE   	try {           http_request = new ActiveXObject("Msxml2.XMLHTTP");        } 	catch (e) 		{           try {               	 http_request = new ActiveXObject("Microsoft.XMLHTTP");			   } 		   catch (e) {}       }   }   if (!http_request) {       alert('Browser doesn\'t support AJAX');       return false;   }      http_request.onreadystatechange = function()		{			if (http_request.readyState == 4) 			{			                                        // if there was no problem with the response (e.g. 401, 404 ... response)          			                                       if (http_request.status == 200)          			        {          				  document.getElementById("div").innerHTML += ajaxRequest.responseText;          				            				  if (ajaxRequest.responseText.toString() != "<br><b>Welcome to destination - Hope you enjoyed your trip</b>" )           				     {                                               alert ('Seems we are ending');                                               cleartimer(t);                                               }             		                }             		                            			   else            			       {            				   alert('There was a problem with the request: Error code: ' + http_request.status);	                                   cleartimer(t);            			       }					       }              }  return http_request;}function start() {  //  alert('start');  do {         // alert('in do');     ajaxRequest.open("GET", "next_instruction.php", true);     ajaxRequest.send(null);  }  while (ajaxRequest.responseText.toString() != "<br><b>Welcome to destination - Hope you enjoyed your trip</b>" )   alert ('Destination reached');}//main codealert ('Starting running');var ajaxRequest = ajaxFunction();var t = setInterval(function () { start(); }, 2000);</script></head><body><div id="div"></div></body></html>