Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allows the X-CSRF-Token to be skipped optionally

This is necessary for doing any sort of cross-domain request when using backbone-rails.
  • Loading branch information...
commit 91de401e5e43103fd3eedc918792d18632c6f639 1 parent d6ca4c8
@chrisnicola chrisnicola authored Chris Nicola committed
Showing with 4 additions and 3 deletions.
  1. +4 −3 vendor/assets/javascripts/backbone_rails_sync.js
View
7 vendor/assets/javascripts/backbone_rails_sync.js
@@ -23,9 +23,10 @@
type: type,
dataType: 'json',
beforeSend: function( xhr ) {
- var token = $('meta[name="csrf-token"]').attr('content');
- if (token) xhr.setRequestHeader('X-CSRF-Token', token);
-
+ if (!options.noCSRF) {
+ var token = $('meta[name="csrf-token"]').attr('content');
+ if (token) xhr.setRequestHeader('X-CSRF-Token', token);
+ }
model.trigger('sync:start');
}
}, options);
Please sign in to comment.
Something went wrong with that request. Please try again.