Jump to content

[SOLVED] Can you pass a variable to the function called after readystate = 4?


RIRedinPA

Recommended Posts

is it possible to do this?

 

xmlHttp.onreadystatechange=function(variable) {

if(xmlHttp.readyState==4) {

variable.innerHTML = xmlHttp.responseText;

}

}

 

//make sure ? is in qstring, not page

xmlHttp.open("GET", thepage + qstring, true);

  xmlHttp.send(null);

Yes, but you don't even need to add it to the function arguments. This will work:

function doStuff(variable){
var url = 'ajax.php';
http.open('GET', url, true);
http.send(null);
http.onreadystatechange=function(){
	if(http.readyState==4){
		variable.value = http.responseText;
	}
}
}

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.