Ajax calls using jQuery in Ruby on Rails

June 7th, 2008 by Justin Ball

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.

Tags:   · · · No Comments

Leave A Comment

0 responses so far ↓

  • There are no comments yet.