Threaded View

  1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    5
    Vote Rating
    0
    semanticart is on a distinguished road

      0  

    Default Answered: How can I set global http headers for ajax requests?

    Answered: How can I set global http headers for ajax requests?


    I want to send the device ID in every request to my server. What's the easiest way to globally set headers without regard to what store is being used (inline or a defined class)?

    I came up with this, which works but feels rather hacky:

    Code:
    Ext.override(Ext.data.proxy.Ajax, {
      constructor: function(config) {
        config.headers || (config.headers = {});
        config.headers.uuid = 'SOME-EXAMPLE-UUID';
        return this.callOverridden([config]);
      }
    });
    I'm new to Sencha Touch, so any help is appreciated.