var csrf_token = "IjUwMTE5NjY2NWM0ZjBiNGJhNjk1OWYxZDFhZGI1MzczMWVkZmJiMDki.GizSfg.noxr8uAsIPjZEOpT1ad2FjhO9nQ"; $.ajaxSetup({ beforeSend: function(xhr, settings) { if (!/^(GET|HEAD|OPTIONS|TRACE)$/i.test(settings.type) && !this.crossDomain) { xhr.setRequestHeader("X-CSRFToken", csrf_token); } } });