Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jul 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    turn asynch callbacks into synchronous flow?

    Hi all,
    I need to do something unusual. Say a user is browsing my site, and before they navigate away, I need to perform some actions like logging them out, for which they would need some data from the server. On onunload, a SJAX request (AJAX with that parameter as false) is issued, code flow hangs, and when the result comes in, code flow resumes and does what it needs to. If AJAX were used, the script would unload and never get the callback.
    Ok. So that's what I want. The problem is that I'm dealing with something other than an XMLHttpRequest object, and I can't simply supply a false parameter to the request function. I'm looking for some way to wrap an asynchronous routine of this object into a synchronous one. If call var result = myobject.get(data_to_send), code flow here hangs WHILE myobject calls this funky XMLHttpRequest-like object in asynchronous mode, waits for the callback, the callback is called, and myobject returns the result. So code stops synchronously outside of myobject.get, but waits asynchronously inside. Is that possible?

  • #2
    Regular Coder
    Join Date
    Mar 2008
    Posts
    301
    Thanks
    2
    Thanked 30 Times in 30 Posts
    Quote Originally Posted by Coolness View Post
    this funky XMLHttpRequest-like object
    I have to ask. Can you .zip up as an attachment to any reply the "funky X-like object"? I'd be curious to see.

  • #3
    New to the CF scene
    Join Date
    Jul 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    there's no object to zip unfortunately. I'm writing for a program which intercepts a name://blah, then calls a passed javascript function as a result. But once I POST or GET to name://blah, it's completely asynchronous until I receive the callback, and I need to to be synchronous. For simplicity I called it a funky XMLHttpRequest-like object


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •