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]
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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.