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