Jump to content

need urgent help on ajax


Recommended Posts

Hey there.  so I have a javascript file that submits to a php file to do the work.  I'm running into a problem where my readyState is stuck at 1 which means the  httpObject.send(null); did not work.  when i put alerts before and after it though it works properly!  I don't understand why and really need to fix this.

//run when shout form is submitted
function submitShout(){
httpObject = getHTTPObject();

name = getElement("nameID");
city = getElement("cityID");
shout = getElement("shoutID");
submitted = getElement("submitID");

if (httpObject != null) {
	httpObject.open("GET", "shoutupdate.php?submit="+submitted.value+"&shouter="+name.value+"&city="+city.value+"&shout="+shout.value, true);
	alert("before");
	httpObject.send(null);
	alert("after");
	httpObject.onreadystatechange = setOutput("outputID");
}

document.form.reset();
}

 

//set output span of given page
function setOutput(id){

var output = getElement(id);
if(httpObject.readyState == 4){

	output.innerHTML = httpObject.responseText;

}
else if(httpObject.readyState == 0){
	output.innerHTML = "ready state = 0";
}
else if(httpObject.readyState == 1){
	output.innerHTML = "ready state = 1";
}
else if(httpObject.readyState == 2){
	output.innerHTML = "ready state = 2";
}
else if(httpObject.readyState == 3){
	output.innerHTML = "ready state = 3";
}
else{
	output.innerHTML = "<img src=\"images/waiting.gif\"/>";	
}
}

 

anybody have any ideas?  thanks!

Link to comment
https://forums.phpfreaks.com/topic/115149-need-urgent-help-on-ajax/
Share on other sites

httpObject = getHTTPObject();

Whats that meant to do? - I dont see if defined anywhere.

 

the line after it- type:

alert(httpObject);

what does your popup display?

 

dont post as "urgent" or no one will help ( or at least youll decrease your chance of a reply) - http://www.phpfreaks.com/page/forum-rules

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.