Hi Bryan,

The docs for the PeriodicalUpdater[1] say that it supports all of the
standard Ajax.Options[2], and so I would expect onSuccess, onComplete,
etc. to work.  But there's a note at the bottom of the PU docs saying
specifically to use onSuccess since onComplete is "hijacked" for
another purpose (it appears to get fired when you stop the PU via the
stop() method).

So use onSuccess:
* * * *
pe = new Ajax.PeriodicalUpdater(target, url, {
        onSuccess:  function() {
            /* Your code here */
* * * *

If for some other reason you want to have script code in the retrieved
content get executed, include a script tag in the content and specify
the evalScripts: true option in the PU's options:
* * * *
pe = new Ajax.PeriodicalUpdater(target, url, {
        evalScripts: true,
        onSuccess:  function() {
            /* Your code here */
* * * *

T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available

On Apr 26, 10:27 pm, BryanG <bgond...@gmail.com> wrote:
> I'm trying to call a JavaScript function every time PeriodicalUpdater
> makes a request (so I can check the response to see if the
> PeriodicalUpdater needs to be stopped).
> I've tried numerous methods - creating a responder for OnComplete,
> passing an OnComplete callback, and having the web page that
> PeriodicalUpdater calls return A JS call to the function - nothing has
> worked (the first two caused the function to be executed only once,
> not every time a PU was performed).
> I've tried both prototype 1.6.1_rc2 and and get the same
> response.  I've also tried searching through the group, but have not
> come across anyone with this same issue.
> Here's the web page code I'm using:
> var updater = Ajax;
> function init() {
>   updater = new Ajax.PeriodicalUpdater('', 'get_status2.php', {evalJS:
> true, evalScripts: true, method: 'get', frequency: 1, decay: 1 });
> }
> And here's the output I'm sending from get_status2.php (I've tried
> this both with and without the header of the response containing a
> "Content-type" of "text/javascript"):
> <script type="text/javascript">alert("null");</script>
> I do see this response being returned properly in Firebug.  I've tried
> this on FF 3.0.9 and IE and get same result.
> Was wondering if anyone had any ideas of what I might be doing wrong
> (this is my first time using Prototype, so feel free to suggest
> "stupid" mistakes), or had a suggestion of how to solve this problem.
> Obviously, I've got a different function that I plan to use to check
> the response and stop the PU if needed - I think I'll be OK there, but
> I just can't get a function to be called on every update.
> Thanks,
> Bryan
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to