Chris wrote:
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 method returns
immediately, and the callback function is called shortly thereafter...
virtually immediately.
I want to find a way to simplify my code by finding a way to simulate
synchronous behavior for those functions. It's a little awkward to
have to string together calling functions and callbacks all over the
place, particularly when I need to maintain some kind of state between
those calls. The "user experience" is unlikely to suffer with a
synchronous model, IMO, since these async methods always return very
quickly.
So, how can I best simulate synchronous behavior when dealing with
asynchronous functions?
Perhaps show us what exactly you are doing, which API, which objects,
which methods in IE you are using which require a callback function and
then maybe we can tell us whether there is a synchronous way. If you are
using MSXML and its XMHTTP request object for instance then the open
method has a third argument that you can set to false if you really want
synchronous processing. But that blocks the browser while the request is
sent, the answer is received and processed so it is usually not a good
idea even if you think that it normally happens "virtually immediately".
--
Martin Honnen
http://JavaScript.FAQTs.com/