Unable to check CSRF token for jQuery file download, only for IE 9, Rails 3 application

So, I use jquery file upload in rails 3 application, and everything works beautifully, well, except for IE 9. Only in IE9, when I try to download the file, I keep getting the "can not verify csrf token" error in my console. I installed Firebug lite to check it, and the correct csrf token is correct and is in the right place in the document (and yes, I have the <% = csrf_meta_tags%> tag in the header of the layout file). Not sure why it only does this in IE 9, has anyone seen this before?

+7
source share
1 answer

I had the same problem and the above comment from OP helped me find the answer. Here is what worked for me:

$('#fileupload').fileupload({ ... other options formData: [ { name: 'authenticity_token', value: $('meta[name="csrf-token"]').attr('content') } ] }); 

Note that the layout file (application.html.erb in Rails 3.2) should have the following:

  <%= csrf_meta_tags %> 
+20
source

All Articles