Jump to content

ajax script doesn't end (readystate not turning 4)


mr.glue

Recommended Posts

hi,
I have a script which works fine, up until I call it after a certain action - then every time I call that script it doesn't eved ([color=gray]xmlHttp.readyState==4 || xmlHttp.readyState=="complete"[/color] NEVER TRUE). From some reason, this action (which executes perfectly as far as I know) stucks the first action, which works fine until the second executes.

[code]
function getPage(section, url, params) {
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null) {
alert ("Browser does not support HTTP Request")
return
}
switch(section) { 
case "addcomment": -- second action, which stucks the comments list
elemID = "comError"
xmlHttp.onreadystatechange=resultAddComment
break
case "commentslist":
elemID = "txtComments" -- first action: works perfectly until addcomment executes
xmlHttp.onreadystatechange=gotComments
break
}
xmlHttp.open("POST",url,true)
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", params.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(params)
}

...

getPage("commentslist","actions/GetComments.asp", "appropriate_params_here"); // execute 1st action - workds perfectly
getPage('addcomment', 'actions/AddComment.asp', "appropriate_params_here"); // execute 2nd action
getPage("commentslist","actions/GetComments.asp", "appropriate_params_here"); // execute 1st action -- doesn't work now... readystate never complete/4

[/code]
I'm not sure what this:
xmlHttp.setRequestHeader("Connection", "close");

Even does, unless that is similar to the "abort" command.

Secondly, where is your function to return the content?  I don't even see a call to any kind of handler.

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.