Skip to content

Instantly share code, notes, and snippets.

@EdwardIII
Created July 10, 2013 16:27
Show Gist options
  • Save EdwardIII/5967794 to your computer and use it in GitHub Desktop.
Save EdwardIII/5967794 to your computer and use it in GitHub Desktop.
$.ajaxSetup({
beforeSend: function(xhr, settings) {
if (!csrfSafeMethod(settings.type) && sameOrigin(settings.url)) {
// Send the token to same-origin, relative URLs only.
// Send the token only if the method warrants CSRF protection
// Using the CSRFToken value acquired earlier
xhr.setRequestHeader("X-CSRFToken", csrftoken);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment