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" <[EMAIL PROTECTED]> wrote:
> On Jan 22, 2008 11:13 AM, Karel Minarik <[EMAIL PROTECTED]> 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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to