473,387 Members | 1,502 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Synchronous JScript POST functions?

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? Or
shed light on other ways of accomplishing the same thing?

Jul 23 '05 #1
1 3773


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.XMLHTTP')
) 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.open('POST', 'whatever.php', true);
is asynchronously (preferred way but needs an onreadystatechange event
handler) while
httpRequest.open('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/
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

29
by: Christopher Brandsdal | last post by:
If I have a .ASP page that runs JScript code - is it possible to include an ..ASP page that runs VBscript???
1
by: Chris | last post by:
Hi. I have a ibrary I'm trying to use via javascript within IE. This library uses an asynchronous model where I call into a function and pass it a callback function as one of its arguments. My...
1
by: Rashad Rivera | last post by:
Hi Gang, My question is directed more towards the MS JSctip.NET dev team. I understand that you guys are planning to implement events in the newer versions of JS.NET, but is there a way to...
7
by: RFS666 | last post by:
Hello, I would like to use variables with a type in jscript.NET. I declare them as follows: var x : double = 5.03; This doesn't work in my script, that I write to the page in codebehind with...
9
by: WRH | last post by:
Hello I am new to asp but I made some Jscript functions which work fine. The functions contain some strings used as a registration key for some apps. It is important that these strings not be...
1
by: RFS666 | last post by:
Hello together, I wanted to ask if somebody can help me with accessing a listbox (a serverside webform from the designer-toolbox) from clientside JScript. I need to add and remove values and...
2
by: duncansinclair | last post by:
The following code works in IE, but in Forefox (1.0.7 & 1.5) the Asyncronous function (testA) works fine but the Synchronous one (testS) does not. It just doesn't work & I get no errors. ...
3
by: Pro1712 | last post by:
Hi, this may be a stupid question: How can I can call the DoWork-function of a BackgroundWorker synchronous? Or in other words: How can I extend the BackgroundWorker class with a function...
0
by: andrewwan1980 | last post by:
Sorry, all the code in my thread post is meant to be server-side. So if there is not a RUNAT="Server" in the SCRIPT tag then I just forgot and it should be written. Please have in mind this is all...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.