PeriodialUpdater does not like URL with port specified

8 views
Skip to first unread message

Karel Minarik

unread,
Jan 22, 2008, 5:22:10 AM1/22/08
to Ruby on Rails: Spinoffs
Hi all,

I am playing with PeriodicalUpdater an it seems, that it doesn't like
port specified in URL. This does not fire anything when I look in
Firebug:

new Ajax.PeriodicalUpdater('chat', 'http://localhost:4567',
{asynchronous:true, frequency:3});

Without the port everything runs fine. Any ideas how this could be
fixed?

Thanks!,

Karel

Justin Perkins

unread,
Jan 22, 2008, 10:53:11 AM1/22/08
to rubyonrail...@googlegroups.com
On Jan 22, 2008 4:22 AM, Karel Minarik <karel....@gmail.com> wrote:
> I am playing with PeriodicalUpdater an it seems, that it doesn't like
> port specified in URL.

With Ajax requests, you do not specify a port or a hostname.
Everything is relative to the URL in the address bar. This is
explicitly disallowed as part of the Ajax "standard".

-justin

Karel Minarik

unread,
Jan 22, 2008, 12:13:02 PM1/22/08
to Ruby on Rails: Spinoffs
Hi Justin,

thank you very much -- I have discovered the warning about ports @
http://www.prototypejs.org/learn/introduction-to-ajax an hour or so
ago :) I guess it should be repeated at documentation chapters for
relevant functions (Request, Update, PeriodicalUpdater) as well...

Actually I now battle another problem. When I have something this:

new Ajax.PeriodicalUpdater('chat', 'http://localhost:4567/listen',
{ asynchronous:true,
frequency: 1,
method: 'get',
insertion: Insertion.Top }
);

and the server responses with simple:

<p>Message</p>,

it is repeated four times... When I don't specify insertion param,
then it overwrites the content (which is correct), but this preferred
method for *updating* the contents does not work for me... Maybe I am
again overseeing something basic... Thanks for any help or kick
again...

Cheers,

Karel



On Jan 22, 4:53 pm, "Justin Perkins" <justinperk...@gmail.com> wrote:

Justin Perkins

unread,
Jan 22, 2008, 1:51:24 PM1/22/08
to rubyonrail...@googlegroups.com
On Jan 22, 2008 11:13 AM, Karel Minarik <karel....@gmail.com> wrote:
> When I don't specify insertion param,
> then it overwrites the content (which is correct), but this preferred
> method for *updating* the contents does not work for me... Maybe I am
> again overseeing something basic... Thanks for any help or kick

Your request should look like this (you DO NOT want to specify the
protocol, hostname or port)

new Ajax.PeriodicalUpdater('chat', '/listen',


{ asynchronous:true,
frequency: 1,
method: 'get',
insertion: Insertion.Top }
);

What results are you getting?

-justin

Karel Minarik

unread,
Jan 22, 2008, 4:00:36 PM1/22/08
to Ruby on Rails: Spinoffs
Hi Justin,

you are right, the host, port, etc. are not needed and there should be
simply '/listen'. It works however even when I call Ajax with port --
the page itself just must be loaded at the same host, same port
(http://localhost:4567 in my case -- the default Sinatra [http://
sinatra.rubyforge.org] port).

BUT, the bigger problem is, that Ajax.PeriodicalUpdater keeps
inserting *more* elements than it receives from the server. I have
this code:

new Ajax.PeriodicalUpdater('chat_message', '/listen',
{ asynchronous:true,
frequency: 3,
method: 'get',
insertion: Insertion.Bottom }
);

This inserts four, five, fifteen elements in the <div id="chat"></
div>. Which effectively hinders *updating* the div content. After
frustratingly long time I rolled some periodical updater myself:

var Application = {

run : function() {
this.updater = new Ajax.Updater('chat_message', '/listen',
{ asynchronous:true,
method: 'get',
insertion: Insertion.Bottom }
);
},

start: function() {
this.interval = setInterval('Application.run()', 2000);
},

stop : function() {
clearInterval(this.interval);
this.updater = null;
},
}

Which *correctly* inserts only the elements returned fromm the
server... So I consider my problem solved, albeit not in an desired
way.

I don't know if this is some failure or misunderstanding on my part or
something goes weird inside Prototype...

Any ideas?

Karel

On Jan 22, 7:51 pm, "Justin Perkins" <justinperk...@gmail.com> wrote:

Justin Perkins

unread,
Jan 22, 2008, 5:49:41 PM1/22/08
to rubyonrail...@googlegroups.com
On Jan 22, 2008 3:00 PM, Karel Minarik <karel....@gmail.com> wrote:
> BUT, the bigger problem is, that Ajax.PeriodicalUpdater keeps
> inserting *more* elements than it receives from the server.

OK, now we're getting somewhere. This sounds like the same issue as
discussed in this conversation:
http://groups.google.com/group/rubyonrails-spinoffs/browse_thread/thread/a96416ef48cf4c01

Might want to start following that thread to figure out what's going
on. I am using PeriodicalUpdater is many places and have not had any
issues like this, so not sure if it's an usage problem or what.

What version of prototype are you using?

-justin

Karel Minarik

unread,
Jan 23, 2008, 4:59:23 AM1/23/08
to Ruby on Rails: Spinoffs
Hi,

I am using version 1.6.0 (double-checked now). Maybe the weirdness
from another thread is related, but my problem is actually something
else: I just want to *update* (ie. append) contents of some element,
not replace it. The documentation says giving a parameter `insertion`
is the right way to do it. In essence -- yes, but in my case only for
the Ajax.Updater, not Ajax.PeriodicalUpdater. If someone familiar with
the library could have a look inside prototype.js, it would be great.

Does this simple example work for you, Justin?

new Ajax.PeriodicalUpdater('some_div', '/some_file',
{ asynchronous:true,
frequency: 3,
method: 'get',
insertion: Insertion.Bottom
}
);

Thanks!!

Karel

On Jan 22, 11:49 pm, "Justin Perkins" <justinperk...@gmail.com> wrote:
> On Jan 22, 2008 3:00 PM, Karel Minarik <karel.mina...@gmail.com> wrote:
>
> > BUT, the bigger problem is, that Ajax.PeriodicalUpdater keeps
> > inserting *more* elements than it receives from the server.
>
> OK, now we're getting somewhere. This sounds like the same issue as
> discussed in this conversation:http://groups.google.com/group/rubyonrails-spinoffs/browse_thread/thr...

Justin Perkins

unread,
Jan 23, 2008, 9:46:31 AM1/23/08
to rubyonrail...@googlegroups.com
On Jan 23, 2008 3:59 AM, Karel Minarik <karel....@gmail.com> wrote:
> Does this simple example work for you, Justin?
>
> new Ajax.PeriodicalUpdater('some_div', '/some_file',
> { asynchronous:true,
> frequency: 3,
> method: 'get',
> insertion: Insertion.Bottom
> }
> );
>

Yes, I tried that exact snippet and it worked fine. An example
response from the /some_file URL is:

<p>I made it. {{ insert timestamp here }}</p>

-justin

Karel Minarik

unread,
Jan 24, 2008, 5:32:17 AM1/24/08
to Ruby on Rails: Spinoffs
OK, I have made a simple, plain HTML test, see pastie:

--> http://pastie.textmate.org/142692

The results when run simply from the disk (file://...), Prototype
version 1.6.0:

* Mac Firefox, Mac Safari, Win Firefox: Behaves weird, insert more
than one element (three, four, etc)
* Win IE6: Doesn't insert anything

Could someone compare this in his/her environment?

Should this be moved to Prototype-Core?

Thanks,

Karel

On Jan 23, 3:46 pm, "Justin Perkins" <justinperk...@gmail.com> wrote:

Tobie Langel

unread,
Jan 24, 2008, 5:58:20 AM1/24/08
to Ruby on Rails: Spinoffs
Please grab the latest trunk version.

That's a bug that was corrected.

Best,

Tobie

Richard Quadling

unread,
Jan 24, 2008, 6:03:31 AM1/24/08
to rubyonrail...@googlegroups.com
Insertion is deprecated in V1.6.0.1

So, not exactly sure what you SHOULD be doing instead.

(I disable my deprecated section).

In debugging, I get an exception.

e.name = 'TypeError'
e.message = "Access is denied."
e.number = -2147024891
e.description = e.message

This is on IE7 on WinXPSP2.
Works fine on FF.


Add this to the PeriodicalUpdater params

onException: function() { alert('It has all gone a bit Pete Tong.'); }

On 24/01/2008, Karel Minarik <karel....@gmail.com> wrote:
>
> OK, I have made a simple, plain HTML test, see pastie:
>
> -->http://pastie.textmate.org/142692
>
> The results when run simply from the disk (file://...), Prototype
> version 1.6.0:
>
> * Mac Firefox, Mac Safari, Win Firefox: Behaves weird, insert more
> than one element (three, four, etc)
> * Win IE6: Doesn't insert anything
>
> Could someone compare this in his/her environment?
>
> Should this be moved to Prototype-Core?
>
> Thanks,
>
> Karel
>

> On Jan 23, 3:46pm, "Justin Perkins" <justinperk...@gmail.com> wrote:
> > On Jan 23, 2008 3:59 AM, Karel Minarik <karel.mina...@gmail.com> wrote:
> >
> > > Does this simple example work for you, Justin?
> >
> > > new Ajax.PeriodicalUpdater('some_div', '/some_file',
> > > { asynchronous:true,
> > > frequency: 3,
> > > method: 'get',
> > > insertion: Insertion.Bottom
> > > }
> > > );
> >
> > Yes, I tried that exact snippet and it worked fine. An example
> > response from the /some_file URL is:
> >
> > <p>I made it. {{ insert timestamp here }}</p>
> >
> > -justin
> >
>


--
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"

Richard Quadling

unread,
Jan 24, 2008, 6:08:01 AM1/24/08
to rubyonrail...@googlegroups.com

Hmm.

I used http://prototypejs.org/assets/2007/11/6/prototype.js (1.6.0)
and it goes odd in FF (duplicate entries made).

Normally I use SVN trunk and make my own release for testing.

So, using trunk upto changeset 8714, it works in Win FF 2.0.0.11 on
WinXPSP2, but not in IE7 on WinXPSP2

Joy!

Tobie Langel

unread,
Jan 24, 2008, 6:23:01 AM1/24/08
to Ruby on Rails: Spinoffs
File protocol is broken in IE7.

It's a known issue.

One we'll need to code around by defaulting to ActiveX.

Please feel free to open a ticket regarding this.

Best,

Tobie

On Jan 24, 12:08 pm, "Richard Quadling" <rquadl...@googlemail.com>
wrote:
> On 24/01/2008, Richard Quadling <rquadl...@googlemail.com> wrote:
>
>
>
> > Insertion is deprecated in V1.6.0.1
>
> > So, not exactly sure what you SHOULD be doing instead.
>
> > (I disable my deprecated section).
>
> > In debugging, I get an exception.
>
> > e.name = 'TypeError'
> > e.message = "Access is denied."
> > e.number = -2147024891
> > e.description = e.message
>
> > This is on IE7 on WinXPSP2.
> > Works fine on FF.
>
> > Add this to the PeriodicalUpdater params
>
> > onException: function() { alert('It has all gone a bit Pete Tong.'); }
>

Karel Minarik

unread,
Jan 24, 2008, 7:48:37 AM1/24/08
to Ruby on Rails: Spinoffs
Hi,

thanks, Tobie, the trunk version behaves correctly -- ie. it does not
insert mupltiple elements.

Anyone experiencing this issue, grab the version 1.6.0.1 or higher.

Cheers,

Karel
Reply all
Reply to author
Forward
0 new messages