On my site, I have a simple model called Feed.
I want to create a link / button that will pull the feed record with id = 5 (for example) using AJAX.
The record that has been drawn should be partially displayed.
How can I do this?
thanks,
odd
Use, you can work like this:
In your controller you should respond_to answer the AJAX request: JS So you can either provide direct javascript on your site, or the way I suggest you, presenting Jason and parsing it on the client side.
class YourController & lt; ApplicationController The code is not checked, but it's working like this Note: The console works with Firefox, but not with Safari, using firebug for console output. In practice. DEF Index @ Model = YourModel.all respond_to do | Format | Format.html format.json {Render: Jason = & gt; On the client side, just force one click handler and then get the data using the path of your controller: Click
$ ("# your_link_id") (function () {$ .getJSON ('/ path_to_your_controller', function (data) {console.log (data);})}}
Comments
Post a Comment