Brad wrote:
A long-time JScript/IE programmer friend of mine shared a technique
with me recently that puzzles me. He has a series of functions that
perform POSTs, with each function returning a dummy value. He has a
dummy variable in the calling code to catch it. He said that by both
returning and catching this dummy value, the POSTs perform
synchronously, whereas if there were no values caught in the calling
code, they would perform asychronously. Sort of like this:
var dummy1 = PostFunction1() ;
var dummy2 = PostFunction2() ;
where each PostFunctionX does a POST, and returns something like
'ignoreMe'.
I looked around and couldn't find any documentation detailing this
technique anywhere. Can someone point me to information about it?
Not really, we need to guess, if you are talking about a HTTP POST then
I guess those functions (e.g. PostFunction1) which you didn't bother to
show us use MSXML (e.g.
var httpRequest = new ActiveXObject(' Microsoft.XMLHT TP')
) and then make a HTTP POST request with it, then there is no magic to
it as to whether processing is synchronous or asynchronous, the third
parameter of the open method determines that e.g.
httpRequest.ope n('POST', 'whatever.php', true);
is asynchronously (preferred way but needs an onreadystatecha nge event
handler) while
httpRequest.ope n('POST', 'whatever.php', false);
opens a synchronous requests (not preferred as it blocks the browser but
that gives you a way to have the script wait and return a value).
Docs are on
http://msdn.microsoft.com/, look for MSXML.
But as said we need to guess, if those functions use/do something else
then obviously what I told you and pointed to you doesn't help, so
provide some details and then maybe we can identify what is done.
--
Martin Honnen
http://JavaScript.FAQTs.com/