Created
September 2, 2015 05:31
-
-
Save 0xnbk/45934f5fa7d56830656c 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
// app.js | |
$.ajaxSetup({ | |
// force ajax call on all browsers | |
cache: false, | |
// Enables cross domain requests | |
crossDomain: true, | |
// Helps in setting cookie | |
xhrFields: { | |
withCredentials: true | |
}, | |
beforeSend: function (xhr, type) { | |
// Set the CSRF Token in the header for security | |
if (type.type !== "GET") { | |
var token = Cookies.get("XSRF-TOKEN"); | |
xhr.setRequestHeader('X-XSRF-Token', token); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment