Created
September 8, 2015 12:34
-
-
Save kostnikolas/4bd74078db8e4167d3ad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getCookie = (name) -> | |
for cookie in document.cookie.split ';' when cookie and name is (cookie.split '=')[0] | |
return decodeURIComponent cookie[(1 + name.length)...] | |
null | |
$.ajaxSetup | |
beforeSend: (xhr, settings) -> | |
unless (/^http:.*/.test settings.url) or (/^https:.*/.test settings.url) | |
xhr.setRequestHeader "X-CSRFToken", getCookie 'csrftoken' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment