View Full Version : Adding Source of Ajax Call as Parameter

13 Apr 2018, 8:02 AM
I have three different areas in my application that can modify hours. They all use the same grid, store, and model (but different instances) along with the same url on the backend. I am trying to implement a way to add a parameter to the ajax calls, so the backend knows which area of the application that the call came from.

I have attempted the following:
1. Overriding request function in Ext.data.Connection

Ext.data.Connection.override({ //add an extra parameter to the request to denote that ext ajax is sending it
request: function(options){
var me = this;
options.params = {};
options.params.location = 'location 1';

return me.callOverridden(arguments);

Result: I couldn't figure out a way to find the module that made the call.

2. Adding the following to the controllers init of the controllers

Ext.Ajax.on('beforerequest', function(conn, options) { if(!options.params)
options.params = {};
options.params.location = "location 1";
Result: Every call was sending the same location even if it was a different area