Skip to content

Instantly share code, notes, and snippets.

@reuf
Forked from Djiit/django-ajax.html
Created September 30, 2015 09:37
Show Gist options
  • Save reuf/1dda58f2c4e4bc97503b to your computer and use it in GitHub Desktop.
Save reuf/1dda58f2c4e4bc97503b to your computer and use it in GitHub Desktop.
django-ajax
<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