Skip to content

Instantly share code, notes, and snippets.

View aashay's full-sized avatar

Aashay Desai aashay

View GitHub Profile
@gcollazo
gcollazo / Backbone.sync_csrftoken.js
Created September 25, 2011 14:56
This is what I did to insert the CSRF token in backbone requests. This works with django.
var oldSync = Backbone.sync;
Backbone.sync = function(method, model, options){
options.beforeSend = function(xhr){
xhr.setRequestHeader('X-CSRFToken', CSRF_TOKEN);
};
return oldSync(method, model, options);
};
@aashay
aashay / Output from console
Created April 24, 2011 23:28
NowJS ClientGroup .on "bug"
24 Apr 16:27:32 - Client 8192318114452064 connected
Adding 8192318114452064. Counter is 0
24 Apr 16:27:39 - Initializing client with transport "websocket"
24 Apr 16:27:39 - Client 4147976329550147 connected
Adding 4147976329550147. Counter is 1
Adding 4147976329550147. Counter is 2
24 Apr 16:27:53 - Initializing client with transport "websocket"
24 Apr 16:27:53 - Client 015604767017066479 connected
Adding 015604767017066479. Counter is 3
Adding 015604767017066479. Counter is 4