prototype 1.6 Ajax.PeriodicalUpdater executing old scripts??

10 views
Skip to first unread message

jin...@gmail.com

unread,
Jan 21, 2008, 7:03:57 PM1/21/08
to Ruby on Rails: Spinoffs
Hello ,

I have a PeriodicalUpdater executing every x seconds and sends a ajax
request to update an element.
Each time it comes back, the element is getting replaced with some
html and and possibly <script>coolFunction()</script>.
This seems to work fine when for prototype 1.5.
However when I upgraded to prototype 1.6, it seems to execute
coolFunction() as many times as the request has been called.

For example: the PeriodicalUpdater has already send out 5 request
already without <script>coolFunction</script>, on the 6th one the
response has a <script>coolFunction</script>. Prototype will call
coolFunction six times.

What is the problem here? I didnt used to have it when I used
prototype 1.5

Any help is appreciated

Justin Perkins

unread,
Jan 21, 2008, 10:12:09 PM1/21/08
to rubyonrail...@googlegroups.com
On Jan 21, 2008 6:03 PM, jin...@gmail.com <jin...@gmail.com> wrote:
> For example: the PeriodicalUpdater has already send out 5 request
> already without <script>coolFunction</script>, on the 6th one the
> response has a <script>coolFunction</script>. Prototype will call
> coolFunction six times.

Well that doesn't sound right at all. Do you have an example page or
at least the HTML/JavaScript that can be used to reproduce this?

-justin

jin...@gmail.com

unread,
Jan 22, 2008, 9:41:36 AM1/22/08
to Ruby on Rails: Spinoffs
HTML:

----------------------------------------------------------------------------------------
<html>
<head></head>
<body onload="start()">
<div id="status"></div>
</div>
</html>
----------------------------------------------------------------------------------------



JAVASCRIPT:
----------------------------------------------------------------------------------------
function start(){
new Ajax.PeriodicalUpdater('status', 'url',
{
method: 'get',
parameters: "action_word=checkTimeout',
evalScripts: true,
frequency: 5,
decay: 1
});
}

function coolFunction(){
alert("I'm cool");
}
----------------------------------------------------------------------------------------


SERVER:
----------------------------------------------------------------------------------------
1st response 5 secs
<input type="hidden" name="timeout" value="" />
2nd response 10 secs
<input type="hidden" name="timeout" value="" />
3rd response 15 secs
<input type="hidden" name="timeout" value="" /
><script>coolFunction();</script>
100th response 500 secs
<input type="hidden" name="timeout" value="" /
><script>coolFunction();</script>

----------------------------------------------------------------------------------------


On the browser:
----------------------------------------------------------------------------------------
1st response 5 secs
nothing
2st response10 secs
nothing
3st response 15 secs
I see alert("I'm cool) 3 times
100th response 500 secs
alerts gets called 100 times
----------------------------------------------------------------------------------------


I know it doesnt make sense, but that's what I'm seeing. Maybe I'm
doing something stupid but why did it work in 1.5 and not work in 1.6.






On Jan 21, 9:12 pm, "Justin Perkins" <justinperk...@gmail.com> wrote:

Matt Foster

unread,
Jan 22, 2008, 4:36:03 PM1/22/08
to Ruby on Rails: Spinoffs
Someone else was just talking about the PU concatenating results
instead of overwriting them.

http://groups.google.com/group/rubyonrails-spinoffs/browse_thread/thread/22249f33eed9876a#84d82d160cc6bc7c

If this is an error, it would be a very simple patch.
Reply all
Reply to author
Forward
0 new messages