PDA

View Full Version : ExtJS _dc parameter won't go away



hermann.s
27 Feb 2014, 8:30 AM
So I am trying to mock server responses using SinonJS.
The _dc parameter was never there in the first request ( it was POST anyway ) but was present for the second and third .

After using Ext.Ajax.disableCaching = false, the parameter is also gone from the second request, but is still there in the third.

This means I cannot match the request with the mock server response because of the extra param.
So I get a response for the first and second request, but not for the third one.
What could be wrong?


it('Simulates services', function () {

this.server = sinon.fakeServer.create();
Ext.Ajax.disableCaching = false;

this.server.respondWith("POST",
ABC.Core.servicePath + '/user/authentication',
[200, { "Content-Type": "application/json" }, '[{"portalID":"admin","authenticated":true,"languageID":1,"language":"en"}]']);

callback = function (text) {
console.log(text.responseText);
};


applicationRepository.authenticateUser(callback);
this.server.respond();

var portalID = 'admin';
var languageID = -1;

this.server.respondWith("GET",
ABC.Core.servicePath + '/localisation?portalID=' + portalID + '&languageID=' + languageID,
[200, { "Content-Type": "application/json" }, '[{"data":true}]']);

callback = function (text) {
console.log(text.responseText);
};


applicationRepository.getLocalisation(callback);
this.server.respond();

this.server.respondWith("GET",
ABC.Core.servicePath + '/grid/column/lists?portalID=' + portalID,
[200, { "Content-Type": "application/json" }, '[{"data":false}]']);

callback = function (text) {
console.log(text.responseText);
};


applicationRepository.getDynamicColumns(portalID, languageID, callback);
this.server.respond();

this.server.restore();
});

scottmartin
27 Feb 2014, 5:45 PM
Set noCache in your proxy



proxy : {
type : 'ajax',
noCache: false, // remove param "_dc"
}

hermann.s
28 Feb 2014, 4:23 AM
There is no proxy or store.
This is just an Ajax request.

Or is there ALWAYS a proxy with every ajax request, and I just don't know about it?

evant
28 Feb 2014, 4:30 AM
Your code shows neither so... we don't know.

hermann.s
28 Feb 2014, 4:34 AM
There is no proxy, or store. So what happens in that case? Why won't the _dc parameter go away?

scottmartin
28 Feb 2014, 5:12 AM
try this


Ext.data.proxy.Server.prototype.noCache = false;


Here are the options available that may help

// disableCaching determines if there will be a timestamp appended to caching; Defaults to: true
Ext.Loader.setConfig({enabled:true, disableCaching: false});

// True to add a unique cache-buster param to "GET" requests:
// Default: TRUE; method === 'GET' && disableCache; Defaults to: true
Ext.data.Connection.disableCaching = false;

// True to add a unique cache-buster param to requests. Defaults to true;
Ext.data.JsonP.disableCaching = false;

// This should disable _dc across all proxy calls
Ext.data.proxy.Server.prototype.noCache = false;

// True to add a unique cache-buster param to GET requests. Defaults to true.
Ext.Ajax.disableCaching = false;

// you did not qualify this statement, Ext.Loader, Ext.JsonP, Ext.data.connection;
// usually with be _dc or _nocache; determines the parameter; defaults to '_dc'
Ext.Loader.disableCachingParam: '';