View Full Version : [FIXED] Ext.Ajax.cors lingers in IE <= 9

6 Jun 2014, 8:22 AM
I posted this in the Ext Support forum (http://www.sencha.com/forum/showthread.php?285919), but wasn't able to get a ticket opened.

We had a production issue for IE 9 where an AJAX request did not have a header we configured as part of the model we were saving.
We traced it back down to the Ext.Ajax.isXdr flag.

The Ext.Ajax class is a singleton instance of the Ext.data.Connection class.
When you call the request method, the Ext.data.Connection.newRequest method is executed, and this line runs:

} else if ((options.cors || me.cors) && Ext.isIE && Ext.ieVersion <= 9) {
xhr = me.getXdrInstance();
me.isXdr = true;
} else {

ExtJS 5 does the same, but calls me.setIsXdr(true).

The problem with this logic is that the flag is never reset.
After you do one Ext.Ajax.request with cors:true, every AJAX call will use xdr, even if the request sets cors: false.
A side effect of this is that headers will not be sent after the cors flag is set, but they will be sent before.

To reproduce this issue, run the following code in ExtJS 4 and 5, in IE <= 9, and look at the network traffic:

function getIsXdr() {
return (Ext.Ajax.getIsXdr ? Ext.Ajax.getIsXdr() : Ext.Ajax.isXdr);

Ext.onReady(function () {
alert('isXdr: ' + getIsXdr());
url: '//' + window.location.hostname,
cors: true
alert('isXdr: ' + getIsXdr());
url: '//' + window.location.hostname,
headers: {
Accept: 'application/json'
alert('isXdr: ' + getIsXdr());

You'll notice the second request does not have Accept: 'application/json'.
If you flip the order of the requests, it'll send the request header correctly.

This flag does not work as expected when the Ext.data.Connection class is used as the Ext.Ajax singleton.
We were able to work around this issue by creating an Ext.data.Connection instance and doing the request off of it instead.

Phil Guerrant
10 Jun 2014, 8:18 AM
Thanks for the report! I have opened a bug in our bug tracker.