ajax setup
authorMaciej Tronowski <mtro@man.poznan.pl>
Thu, 9 Apr 2015 16:15:49 +0000 (18:15 +0200)
committerMaciej Tronowski <mtro@man.poznan.pl>
Thu, 9 Apr 2015 16:15:49 +0000 (18:15 +0200)
qcg/static/qcg/globals.js [new file with mode: 0644]

diff --git a/qcg/static/qcg/globals.js b/qcg/static/qcg/globals.js
new file mode 100644 (file)
index 0000000..93712a5
--- /dev/null
@@ -0,0 +1,10 @@
+var csrftoken = $.cookie('csrftoken');
+
+$.ajaxSetup({
+    traditional: true,
+    beforeSend: function(xhr, settings) {
+        if (!(/^(GET|HEAD|OPTIONS|TRACE)$/.test(settings.type)) && !this.crossDomain) {
+            xhr.setRequestHeader("X-CSRFToken", csrftoken);
+        }
+    }
+});