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

xmlhttprequest async parameter

Status
Not open for further replies.

Laeg

Programmer
Nov 29, 2004
95
0
0
IE
So I have a db table with two fields, the first field is filled by a call to an external page via xmlhttprequest object and the second field is filled by a script function.
The problem is that although I have set the open method async parameter to false my script still does not wait until processing is finished on foo() function and executes boo(). How can I get the xmlhttprequest object to wait? Any ideas???

While(some condition)
...
foo(foobarid)
bar(foobarid)
Wend

Function foo(foobarid)
' Fills field A
Set objHTTP = CreateObject("Microsoft.XMLHTTP")
objHTTP.open "POST", " False
objHTTP.setRequestHeader "Content-Type", "application/x- objHTTP.send "foobarid=" & server.URLEncode(foobarid)
Set objHTTP = Nothing
End Function

Function bar()
' Fills field B
End Function
 
That looks more like AVAX code, than AJAX. You might wanna try asking in the VBScript forum.

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson

Finally, <. is a good thing!
 

And why not just add bar() into the callback function ? - then it will only fire when/if the foo() function finishes and responds back to the client. using synchronous requests can freeze up the users browser, async is much kinder to the usability of your site.

in fact.. looking at your code... this is server side isn't it? In which case you want to use the server version of the xmlhttprequest.. not the client version as you have here. >> server.createobject("MSXML2.ServerXMLHTTP.4.0").

=======================================
LessThanDot - The IT Community of the 21st Century

A smile is worth a thousand kind words. So smile, it's easy! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top