Jump to content

[SOLVED] wait till onreadystatechange function fires before moving forward


mikesta707

Recommended Posts

is this possible? For example, I have a method in a class that looks like this

function ajaxGet(page){
this.xml = GetXmlHttpObject();
if (this.xml == null){
	alert("This browser does not support AJAX. You will lose some functionality");
	return;
}
url = page;
url += "?q="+this.query+"&t="+document.getElementById(this.ajaxGetId).value;
//alert(url);
newData = null;
this.xml.onreadystatechange = function() {
	if (this.readyState==4){
		newData = new Array();
		newData = this.responseText;
	}
	//this.fill_table();
}
this.xml.open("GET", url, true);
this.xml.send(null);
//I want to wait till the request completes here before I move forward
this.data = newData;
this.fill_table();
}

 

im really stumped. New to AJAX so don't really know how to proceed.

 

the reason I dont use this.data=responseText or this.fill_table() is because the methods in my defined javascript class are out of scope in that function. is there a way I could put them in scope?

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.