PDA

View Full Version : Ext JS 4 and CORS



grdrew
3 Feb 2014, 3:03 AM
Hi,

Has anyone got EXT JS REST proxy to work with CORS?

I have a simple Store using a REST proxy. The URL for a simple GET request is, for example,

'http://server-pc:81/myapp/rest/function/'

If I access my page with this URL,

'server-pc:81/myapp/index.html',

the store proxy works, but, if I use this URL,

'localhost:81/myapp/index.html',

the store proxy fails. This is treated as a CORS request, so I have set Ext.Ajax.useDefaultXhrHeaders to false and Ext.Ajax.cors to true, but for some reason the xhr.responseText is missing in the onreadystatechange function, even though the request succeeds.

Can anyone tell me if CORS actually works in Ext Js?

regards

Gord

Gary Schlosberg
3 Feb 2014, 6:56 AM
It definitely works. What version of ExtJS are you using? Here's a few links that might help:
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.data.Connection-cfg-cors
http://enable-cors.org/

grdrew
4 Feb 2014, 6:37 AM
Hi Gary,

Thanks for the reply. You are right, it does work. I know it sounds unlikely, but as far as I can tell it's Firefox (26.0) that's causing the problem. Just won't handle the CORS request properly. It works fine in IE11 (provided you set compatibility mode to 9 or above).

regards

Gord