Ajax calls using jQuery in Ruby on Rails
jQuery is the hot javascript library and it is small and it is cooler than Prototype, the default library that comes with Ruby on Rails. Ergo I plugged it in and pulled out everything else. The ajax calls are very simple and look like this:
$.post("function_name",{ key:value } ,function(data)
{
// do stuff with data
});
The problem is that you will start seeing 'ActionController::InvalidAuthenticityToken' and your ajax calls will fail.
Here is a very elegant solution.
More from jbasdf
- Rails Conf Intro from Chad Fowler and Some Stuff from the Mountain West Ruby Conference
- Ruby on Rails i18n with the Rails I18n Textmate bundle
- A copy of ApplicationController has been removed from the module tree but is still active! And can’t dup NilClass
- Implicit multipart emails using Ruby on Rails and ActionMailer won’t work
- Mac OSX and the Samsung ML1740 on a network
Justin Ball is a software consultant and entrepreneur with a passion for Ruby. He evolved from a C++ and .Net monkey into a python programmer and finally found Ruby. In the rare moments when he isn't writing code, talking about code or measuring his code productivity in profanity per hour, you can find him on his bike in the mountains or on the roads surrounding Cache Valley. 









