Forum: Rails Spinoffs (closed, excessive spam) Problem with callbacks/onComplete

F6c6f424a8d5711ebe5e7b6301aee1c4?d=identicon&s=25 Martin Taylor (Guest)
on 2008-07-11 02:31
(Received via mailing list)
Here's my situation. Parent browser window opens a popup window. The
popup window contains a form that I'd like to submit to a php script
via ajax. I'd then like the popup window to automatically close (don't
need to display any feedback from the php script).

My popup window calls submitform() when the form is submitted. Here's
the contents of my .js file:

     function ajaxUpdater(id,url) {
           new Ajax.Updater(id,url,{asynchronous:true});
     }

     function submitform() {
         ajaxUpdater('mydiv', 'submit.php?value=' +
                document.getElementById('something').value
           , {
                  onComplete: tidyup()
             }
            );
      }

     function tidyup() {
          window.close();
     }

Before I added the onComplete callback, this was working - in that the
data was submitted to the form. Now though, it seems that window.close
is called before the ajax request is made: watching my server's access
log I don't see submit.php being called. If I comment out
window.close() , I see submit.php being called.

Am I misunderstanding the use of callbacks? I was under the impression
that onComplete would only be fired once the the webserver had
returned a status header in response to the ajax request.

Thanks,
Martin
F490e41cd5de1393a9f6958b70dae6ab?d=identicon&s=25 Frederick Polgardy (Guest)
on 2008-07-11 03:18
(Received via mailing list)
In the future please post to the new group prototype-scriptaculous:

http://groups.google.com/group/prototype-scriptaculous?hl=en

Change to onComplete: tidyup    (not tidyup() which calls a function and
evaluates to its return value)

-Fred

On Thu, Jul 10, 2008 at 7:30 PM, Martin Taylor <test@linuxbox.co.uk>
wrote:

>           new Ajax.Updater(id,url,{asynchronous:true});
>
> Am I misunderstanding the use of callbacks? I was under the impression
> that onComplete would only be fired once the the webserver had
> returned a status header in response to the ajax request.
>
> Thanks,
> Martin
>
> >
>


--
Science answers questions; philosophy questions answers.
This topic is locked and can not be replied to.