title: How do i add the authenticity token?
body: <p>I recently switched to Google closure for a new project. I am having trouble adding the authenticity token to the headers in a ajax call. How do i go about it?</p>
  
  <p>My Ajax snippet (using goog.net.XhrIo class):</p>
  
  <pre><code>var initialHTMLContent = superField[i].getCleanContents();
  
  var data = goog.Uri.QueryData.createFromMap(new goog.structs.Map({
    body: initialHTMLContent
   }));
  
   goog.net.XhrIo.send('/blogs/create', function(e) {
      var xhr = /** @type {goog.net.XhrIo} */ (e.target);
      alert(xhr.getResponseXml());
   }, 'POST', data.toString(), {
      'Accept' : 'text/xml'
              });
  </code></pre>
  
  <p>Using rails in the backend.</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>Log:</p>
  
  <pre><code>Processing BlogsController#create (for 127.0.0.1 at 2010-06-29 20:18:46) [PUT]
    Parameters: {"authenticity_token"=&gt;""}
  
  ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken):
  
  
  Rendered rescues/_trace (272.4ms)
  Rendered rescues/_request_and_response (1.2ms)
  Rendering rescues/layout (unprocessable_entity)
  </code></pre>