troubleshooting Question

IE - Ajax problem - Data necessary to complete this operation is not yet available

Avatar of infernothao
infernothao asked on
JavaScriptWeb BrowsersAJAX
9 Comments1 Solution2820 ViewsLast Modified:
Hi Experts, I'm trying to make a call to ajax which it supposes to return the percentage left while waiting for the file to finish generating info. Everything works fine in Firefox but in IE it generates an error as stated in the topic. It does work in IE but with an error. Below is the javascript I used. If I were to comment out the line after  "ajaxRequest.readyState == 3" (line #37)  it seems to work without any error.
/*---------------------------------------------------------

----------------------------------------------------------*/
function generateCompleteExport(data){
	ajaxRequest = GetXmlHttpObject(); 
	ajaxRequest.async = false;
	if (ajaxRequest==null){
		alert ("Browser does not support HTTP Request")
		return
	} 
	
	var loadingImg = '<img src="/reports/assets/scripts/loading.gif" title="Loading...">';
	document.getElementById('status').innerHTML = loadingImg;
	
	// Add parameter 'q' to URL
	var url = 'completeExportGenerate.php?'+data;	
	// Adds a random number to prevent the server from using a cached file
	url=url+"&sid="+Math.random();	
	
	var numTest =0;
	var response;
	var index;
	
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			if(ajaxRequest.status == 200) {
				response = ajaxRequest.responseText.split("###");
				index = response.length-1;
			
				document.getElementById('status').innerHTML =response[index];
			} else {
				//window.status = "No Update for " + targetId;
				document.getElementById('status').innerHTML="Error code " + ajaxRequest.status;
			}
		}
		if(ajaxRequest.readyState == 3){
			response = ajaxRequest.responseText;.split("###");
			if( (response.length-2)<= 0)
				index = 0;
			else
				index = response.length -2;
				
			document.getElementById('status').innerHTML =loadingImg+'<br>'+response[index];
		}
	}
	ajaxRequest.open("GET", url, true);
	ajaxRequest.send(null);
}
ASKER CERTIFIED SOLUTION
apresence

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros