[Dojo-interest] Re: xdomain and synchronous calls

Erick Feiling starbuckzero at gmail.com
Wed Feb 28 11:53:44 MST 2007


He he he, or you can do that. ^_^

On 2/28/07, tf <troy_forster at hotmail.com> wrote:
>
>  Sten,
>
> I've been using
>
> window.addEventListener("beforeunload", function_name, false)
>
> to trap for a similar situation.  To be fair, it was recently brought to
> my attention that this is not working for one of our users and I suspect it
> is a browser compatibility issue with the beforeunload event, but I have not
> had time to investigate yet.
>
> You may want to investigate the beforeunload event to see if it will work
> for you.  Perhaps you can trap that event and use it to make the asynch
> call?
>
> Troy
>
> "Sten Duncan" <stenduncan at gmail.com> wrote in message
> news:8b78b9ae0702281029m3ac8323djce4f875b6caf1ce5 at mail.gmail.com...
> I am struggling with a problem involving cross-domain processing and the
> page unload action.
>
> Briefly, when the user closes a page (onunload or onbeforeunload) I need
> to make an xdomain call to the server - to unregister the user. I don't know
> until the page is unloading that the call needs to be made so I can't do it
> in advance. The problem is that with an asynch call, once the thread is
> released after the io.bind call, the browser exits almost immediately and
> the server call never gets made.
>
> In a non-xdomain environment, this works fine since I can make the io.bindcall synchronous. But in the xdomain environment, the
> io.bind is by definition asynch (I'm using the iframe proxy:
> XhrIframeProxy).
>
> I've also tried ways to pause the main thread to give the io.bind time to
> execute and return, but as we all know there is no "sleep" in Javascript.
> And if I use something like a timer (setTimeout) I have the same problem
> with the thread being released and the page exiting before the server call
> is made/completed. Putting the main thread into a loop doesn't help either -
> I get the popup telling me that a script appears to have stopped running,
> etc. and this is completely unacceptable for a user app.
>
> Does anyone have any ideas about how to either:
>
> 1. do a synchronous xdomain server call?
> 2. pause the main thread so that an asynch xdomain call has time to
> return?
>
> Any help would be enormously appreciated.
>
>  ------------------------------
>
> _______________________________________________
> Dojo FAQ: http://dojo.jot.com/FAQ
> Dojo Book: http://manual.dojotoolkit.org/DojoDotBook
> Dojo-interest at dojotoolkit.org
> http://dojotoolkit.org/mailman/listinfo/dojo-interest
>
>
> _______________________________________________
> Dojo FAQ: http://dojo.jot.com/FAQ
> Dojo Book: http://manual.dojotoolkit.org/DojoDotBook
> Dojo-interest at dojotoolkit.org
> http://dojotoolkit.org/mailman/listinfo/dojo-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://dojotoolkit.org/pipermail/dojo-interest/attachments/20070228/a8c7a7c7/attachment.html


More information about the Dojo-interest mailing list