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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Basic question about an xml variable instance

Status
Not open for further replies.

jsteph

Technical User
Oct 24, 2002
2,562
US
Hi,
I'm very new to xml, please bear with me. I have a javascript function that is called in a loop, the basics are (this is ie6):

Code:
function testx(url,rownum)
)//url is upddata.asp, rownum is the row of the loop that called this
// req is a global variable for the xml object
if (('' + req) = '') //only create on first loop
   req =  new ActiveXObject("Microsoft.XMLHTTP");

   req.onreadystatechange = processReqChange;
   req.open("POST", url, true
   document.forms.frmmain.txtstatus.value = 'Processing ' + rownum
   req.send();
}//end function testx

Now, this thing is called from another js function that may call it 100 or more times in a loop, passing a different rownumber each time, and a url with the same pagename but different request variables following the url. The url is an asp page that writes to the database based on url request variables.

So the question is--let's say the processing for row 2 takes a long time. So row 3 calls this function and it does the req.open and req.send for row 3--does it affect in any way the already running global instance of req for row 2 (or any other, for that matter)?

Also, the same handler function will be called by each row for the req.open, and I'm wondering how can I know which rownumber/req instance the current instance of processReqChange is handling? I can't use a global row variable because as in the example above--the state changes may and will happen out-of-order, so depending on where I set a global row var, the current state-change may not be the state-change for that row's req.send. And I thought of doing a new object each time, but then I think that would definitely affect the current instance of req, since it's global.

This all is pretty basic and I imagine it's been answered before, so can anyone help out on this?
Thanks,
--Jim
 
i am not that familiar with xml but this sounds more like a question on how not to go into a function or routine while it is still running. Set up a flag inside the routine or function and pass the variable back to your main application. Inside the main application test for the variable with a do while command. When the Subroutine or function is complete make sure the last statement is to set the flag back to the proper value.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top