Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Firefox Hang on Successive Requests

Status
Not open for further replies.

simonB2007

Programmer
Jun 12, 2007
16
GB
Looking for help with a scrip that works on IE, but suffers in Firefox.
Running all locally for now.

Each run of script makes multiple calls to "f_request" (consecutively)
Always calls to same path, at this stage only 1 parameter in the send string changes each time.

In Mozilla:
On first cylce of code, 2 requests are made succesfully.
Upon user interaction, code runs again to make a 3rd call ...but hangs completely upon "req.open"

If i was to give 'feeling' ... its as though the request hasn't terminated properly from the previous call !?
Have tried several setRequestHeader things to prevent caching etc etc ... none to success (included in code below).


Reference Material Below...
(1) Javascript code
(2) .asp script generating responses
(3) Sample call strings (used in req.send(send)) and responses


Hope someone can help as i'm getting hopelessly lost !!

Many thanks
Simon

======================= page.htm

function f_request(s_inData, s_path){

// path to send request
fullPath = s_saveRoot + s_path;

// create request object
try {req = new ActiveXObject("Msxml2.XMLHTTP");}
catch (e) {
try {req = new ActiveXObject("Microsoft.XMLHTTP");}
catch (e) {req = false;}
}

if (!req && typeof req !='undefined') {
try {req = new XMLHttpRequest();}
catch (e) {req=false;}
}
if (!req && window.createRequest) {
try {req = window.createRequest();}
catch (e) {req=false;}
}

req.open("POST",fullPath,true); // **hangs here

req.setRequestHeader("Cache-Control", "no-cache");
//req.setRequestHeader("Connection", "close");
req.setRequestHeader("Content-Type", "application/x-
req.onreadystatechange=sendDone;
req.send(s_inData);
}


======================= dataProvider.asp


<%
Response.ExpiresAbsolute = #2000-01-01#
Response.AddHeader "pragma", "no-cache"
Response.AddHeader "cache-control", "private, no-cache, must-revalidate"

i_usr = request.form("usr")
s_cString = request.form("c")
s_filters= request.form("f")

///// o_cmd is user def function
Set o_cmd = new c_cmd
s_spName = "web_treeFeed_sp"
i_headers =0
o_cmd.CommandTextType s_spName , &H0004
o_cmd.addParamCrit "Usr", adInteger, adparaminput, 4, i_usr
o_cmd.addParamCrit "cString", adVarchar, adparaminput, 12, s_cString
o_cmd.addParamCrit "filters", advarchar, adparaminput, 12, s_filters
o_cmd.setHeaders(i_headers)

s_result = o_cmd.GetData()
Set o_cmd = Nothing
/////

Response.ContentType = "text/xml"

s_out = "<ReturnValue>" &_
s_result &_
"</ReturnValue>"

Response.write s_out
%>

=========================


call send strings ....
inData = usr=1&c=2,1,3,4,5&f=-1
inData = usr=1&c=2,1,3,4,5&f=-1,1
inData = usr=1&c=2,1,3,4,5&f=-1,1,1

scripted responses.....
<ReturnValue>0,1,Art#</ReturnValue>
<ReturnValue>0,1,Ceramic#0,2,Paint-Pencil#</ReturnValue>
<ReturnValue>0,4,Stoneware#</ReturnValue>
 
K, installed firebug, results say that the parameters i'm passing in to f_request are 'undefined' ... yet my own debugger says otherwise.
Anyway, I've hardcoded the request path as a check, and the error persists.

Full code uploaded to :

NB: it will want to open a pop-up/tab which is my internal debugging mechanism.

To replicate the errorm in FF:
Open page until you see "Art" in the menu, Green.
Click on the cross next to "Art" and the menu will expand to reveal 2 sub-nodes.

This is where the next calls kick-in to find sub-nodes of "Cermaic" and "Paint-Pencil"

My debugging page shows the script hanging on req.open
 
yet my own debugger says otherwise
I suggest your own debugger is wrong. I have a lot more faith in Firebug than in your homebrewed solution.

Put in a good old fashioned alert statement in to confirm that these values are not in fact undefined. I suggest using escape to make it more clear what you are alerting. Put these two lines at the very top of the f_request() function:
Code:
alert(escape(s_inData));
alert(escape(s_path));
Let us know how you go!

Cheers,
Jeff


[tt]Jeff's Page [!]@[/!] Code Couch
[/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
On page load, I see 2 post requests to NDR.asp. The first sends:

"c 2,1,3,4,5"
"f -1"
"usr 1"

And the second sends

"c 2,1,3,4,5"
"f -1,1"
"usr 1"

The first never returns, and the second returned "0,1,Ceramic...".

Do you mean to send off 2 requests? Does your server-side code send any response to the first request?

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Ok,
I have found 2 mins to tidy up my dubugging screen to show much more clearly the calls and responses, hope this helps ?

On page open, 2 calls are made and responses shown.
On click "+ Arts" the call is made, but hangs ...


As for the firebug discussion...
I have hardcoded the params for the call so eliminating this issue.
If you still think its important, I have clarified a line in my 'homebrewed' debugger to write the variables as the function starts.
Homebrewed or not, if the arguments were indeed undefined, how could it document.write the values seen ??
The advantage with 'homebrewing' is that you KNOW what is being reported and how.





 
You appear to be using 1 global XMLHTTP object for all your requests. Are you sure you want to be doing this, instead of creating a new one for each request (remember they are asynchronous)?

I ask, as I'm seeing more callbacks coming in than requests going out - which is really weird!

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Yes, 1 object, it collects nodes and adds them to the tree, 1 call at a time.

I have updated the debugger to draw a line '--------' at the start of a call and 'xxxxxxx' when response recived.
I cannot see anymore than 1 respoinse per request ... ??

Whaere are you seeing more ??
 
If I place a breakpoint at line 571 in NTS.js:

Code:
req.onreadystatechange=sendDone;

and at line 593, just inside the sendDone function:

Code:
if(!isUndefined(reqNode.displayNode) && reqNode.parent){

then I see more breaks at the second than at the first. This says to me that more things are running your callback function than are being sent.

Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Thanks for all suggestions .... I suspect the answer does indeed lie in the realm of threads/re-using the req object.

However, I cant understand why, if each time the f_request fnctn is called, the xmlhttpreq object is aborted before a fresh call.

--- reponses to previous suggestions below ----

(1) SendDone is called onreadystatechange, therefore rightly there will be multiple calls to this funct than the number of sends.

(2)abort() : applied to exisitng req object before a new call

(3) ReadyState : the senddone function is an onreadstatechange handler, the script continues to loop senddone until :
if (req.readyState == 4) {
if(req.status == 200){

.. hence we know all initiated calls have completed without error.


 
maybe more specifically ... why does the code work in IE, but not FF ?
 
k, if anyone's still out there... i have new discoveries which change all of this ... sorry !!

new thread coming
(anyone know how to 'close-out' this one ?)
 
simonB2007 said:
(anyone know how to 'close-out' this one ?)

If you want to pretend it never happened, you can 'Red Flag' your own post and type in the explanation to the management. However, since Dan gave some generally decent advice, I would just leave this one here. When you start the new thread, assuming it is with significant new information, then post a reply here that has the thread1600-nnnnnnn string that you will find right under the thread title at the top of the page. The forum software will turn that into a nice link to your new thread.

Tom Morrison
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top