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