Hi all.  I am trying to find a way to insert an authenticity_token
into the params of an Ajax request before it gets sent.
I've got this much:

  Ajax.Responders.register({
    onLoading: function(req){
      if ((req.options.method == 'post') && !
Object.keys(req.options.parameters).include('authenticity_token')){
---->        req.options.parameters.set('authenticity_token',
rails_gen_token());
      }
      alert('method is: ' + req.options.method + '\nparams are: ' +
Object.keys(req.options.parameters));
    },
    onComplete: function(){
      alert('a request completed');
    }
  });

Where you see the arrow is where my problem (obviously) arises.
rails_gen_token() is a function that correctly returns a valid auth
token.  What I don't know is 1. How do I actual modify the parameters
and 2. How can i ensure this happens PRIOR to sending the request?
onLoading doesn't seem to catch it early enough (and isn't guaranteed
to anyway).

Any and all help appreciated!
--~--~---------~--~----~------------~-------~--~----~
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