Sunday, May 30, 2010

[Rails] Re: XMLHttpRequest and Rails

If you're set on doing the ajax through jQuery try adding this to your
page and watch the console logs in firebug (obviously replacing 'posts
and 'index' with the route to the model and action you're polling):

// poll the posts index every 3000 milliseconds logging the response
to the console.
setInterval(function() {
jQuery.getJSON('/posts/index', function(data) {
console.log(data);
});
}, 3000);

This is a pretty crude approach but should illustrate the basics of
getting jquery talking to rails. This does make a request for JSON but
there really isn't any reason you should be using XML over JSON at
this point. Hope that helps.

On May 21, 5:09 pm, Ralph Shnelvar <li...@ruby-forum.com> wrote:
> Is there a simple example of me issuing an XMLHttpRequest and a rails
> app responding ... without all the Prototype overhead.
>
> All I want to do is send an XHR and have the Rails app deliver an XML
> document back.
>
> I have searched ... Does anyone nkow of a decent example?
> --
> Posted viahttp://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
> For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate