All pastes #822388 Raw Edit

Mine

public text v1 · immutable
·published 2007-12-18 18:34 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>
<!-- Dependency -->
	<script src="http://yui.yahooapis.com/2.4.0/build/yahoo/yahoo-min.js"></script>

	<!-- Used for Custom Events and event listener bindings -->
	<script src="http://yui.yahooapis.com/2.4.0/build/event/event-min.js"></script>

	<!-- Source file -->
	<script src="http://yui.yahooapis.com/2.4.0/build/connection/connection-min.js"></script>
</head>

<body>
<div id="container"></div>

<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;
   }
   
}

var div = document.getElementById('container');

var handleSuccess = function(o){
	if(o.responseText !== undefined){
		div.innerHTML +=  o.responseText;
      	}
}

var handleFailure = function(o){
	if(o.responseText !== undefined){
		div.innerHTML = "<li>Transaction id: " + o.tId + "</li>";
		div.innerHTML += "<li>HTTP status: " + o.status + "</li>";
		div.innerHTML += "<li>Status code message: " + o.statusText + "</li>";
	}
}

var callback =
{
  success:handleSuccess,
  failure: handleFailure
};

function cleartimer(t) { clearInterval(t); }

function start() 
{
     var o = YAHOO.util.Connect.asyncRequest('GET', "next_instruction.php", callback);
     
     if (o.responseText == "<br><b>Welcome to destination - Hope you enjoyed your trip</b>") 
        {
          alert ('Destination reached');
          cleartimer(t)
        }

}


//main code  
window.onload = function() { 
    alert('safe to do request now');
    alert ('Starting running');
    var ajaxRequest = ajaxFunction();
    var t = setInterval(function () { start(); }, 2000);
      
}


</script>

</body>
</html>