I have a Backbone application using jQuery and want to append a sessionId
parameter to the URL of all ajax calls?
How can I do this in Backbone or jQuery, maybe in a global way and without rewriting the Backbone.Sync?
So if I have url www.example.com/users
, I want that to become www.example.com/users?sessionId=12314q234123412
You can use the global
.ajaxSend()
event.You can use the advanced options of
jQuery.ajax
. In your case, you should register a global prefilter to modify the sentdata
. Watch out to do this only on request to your own domain, otherwise that could be a security leakage.Another option would be to create a simple wrapper function that extends the options passed in: