I have encountered this just recently and this just solved the problem. Add the codes below to your application.js

function CSRFProtection(xhr) {

var token = $(‘meta[name="csrf-token"]‘).attr(‘content’);
if (token) xhr.setRequestHeader(‘X-CSRF-Token’, token);
}
if (‘ajaxPrefilter’ in $) $.ajaxPrefilter(function(options, originalOptions, xhr) { CSRFProtection(xhr); });
else $(document).ajaxSend(function(e, xhr) { CSRFProtection(xhr); });

function CSRFProtection(xhr) {   var token = $(‘meta[name="csrf-token"]‘).attr(‘content’);    if (token) xhr.setRequestHeader(‘X-CSRF-Token’, token);}if (‘ajaxPrefilter’ in $) $.ajaxPrefilter(function(options, originalOptions, xhr) { CSRFProtection(xhr); });else $(document).ajaxSend(function(e, xhr) { CSRFProtection(xhr); });

Hope this helps :)

 

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>