All pastes #822312 Raw Edit

Yancho

public javascript v1 · immutable
·published 2007-12-18 17:41 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><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 // argument: { foo:"foo", bar:"bar" }};function start() {  //  alert('start');  do {         // alert('in do');     var request = YAHOO.util.Connect.asyncRequest('GET', "next_instruction.php", callback);     //ajaxRequest.send(null);  }  while (o.responseText.toString() != "<br><b>Welcome to destination - Hope you enjoyed your trip</b>" )  alert ('Destination reached');}//main code  window.onload = function() {     alert('safe to do request now');    alert ('Starting running');    var ajaxRequest = ajaxFunction();    var t = setInterval(function () { start(); }, 2000);}</script></head><body><div id="container"></div></body></html>