-
-
Save reuf/1dda58f2c4e4bc97503b to your computer and use it in GitHub Desktop.
django-ajax
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
<polymer-element name="django-ajax" extends="core-ajax"> | |
<script> | |
Polymer({ | |
getCSRFCookie: function() { | |
b = document.cookie.match('(^|;)\\s*csrftoken\\s*=\\s*([^;]+)'); | |
return b ? b.pop() : ''; | |
}, | |
ready: function() { | |
this.super(); | |
this.headers = { | |
"X-CSRFToken": this.getCSRFCookie(), | |
"X-Requested-With": "XMLHttpRequest" | |
}; | |
} | |
}); | |
</script> | |
</polymer-element> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment