2 // Assumes variable csrf_token is made available
3 // by embedding document
5 beforeSend: function(xhr, settings) {
6 if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url))) {
7 // Only send the token to relative URLs i.e. locally.
8 xhr.setRequestHeader("X-CSRFToken", csrf_token);
9 console.log("preparing request to " + settings.url);