Forked from MechanisM/django-ajax-generated-template.html
Last active
August 29, 2015 14:22
-
-
Save inureyes/a5bf22228d8c45a5638e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<link rel="import" href="{{ STATIC_URL }}vendor/polymer/polymer.html"> | |
<link rel="import" href="{{ STATIC_URL }}vendor/core-ajax/core-ajax.html"> | |
<polymer-element name="django-ajax" extends="core-ajax"> | |
<script> | |
Polymer({ | |
ready: function() { | |
this.super(); | |
this.headers = { | |
"X-CSRFToken": {{ csrf_token }}, | |
"X-Requested-With": "XMLHttpRequest" | |
}; | |
} | |
}); | |
</script> | |
</polymer-element> |
This file contains hidden or 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
<link rel="import" href="/assets/vendor/polymer/polymer.html"> | |
<link rel="import" href="/assets/vendor/core-ajax/core-ajax.html"> | |
<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