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