Jump to content

[SOLVED] wait till onreadystatechange function fires before moving forward


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?

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.