All pastes #822967 Raw Edit

Yancho

public javascript v1 · immutable
#822967 ·published 2007-12-19 02:04 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');function cleartimer(t) { clearInterval(t); }var handleSuccess = function(o){	if(o.responseText !== undefined){				if (o.responseText != "") {                  //alert ('Updating route');                div.innerHTML =  o.responseText;                }                else {                   //alert('not updating route');                  }				     if (div.innerHTML == "<br><b>Welcome to destination - Hope you enjoyed your trip</b>")                        {                          alert ('Destination reached');                          return;                        }        window.setTimeout(function(){ start() }, 5000);      	}}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 start() {     var o = YAHOO.util.Connect.asyncRequest('GET', "next_instruction.php", callback);     }//main code  window.onload = function() {     alert('safe to do request now');    alert ('Starting running');    var ajaxRequest = ajaxFunction();    start();}</script></body></html>