PDA

View Full Version : Extjs store.load with id causes CORS error



wayne-oo
27 Aug 2013, 10:06 AM
When I load a store using for a treeview component using the

store: 'somestore'which has the following setup:

Ext.define('App.store.AdminNavigationTree', { extend: 'Ext.data.TreeStore', model: 'App.model.AdminNavigationTree', storeId: 'AdminNavigationTree', headers: { 'Content-Type': 'application/json' }, proxy: { type: 'ajax', url: settings.ApiUrl + '/View/AdminNavigation/?format=json', reader: { type: 'json', root: 'result', } }, folderSort: true});The data loads ok.
When trying to call store.load with the following store with the aim of populating a form it does not!

Ext.define('App.store.PromotionCompany', { extend: 'Ext.data.Store', model: 'App.model.PromotionCompany', storeId: 'PromotionCompany', headers: { 'Content-Type': 'application/json' }, proxy: { type: 'ajax', url: settings.ApiUrl + '/Model/PromotionCompany/?format=json', reader: { type: 'json', root: 'result', } }});I'm using ServiceStack for the API and both of those URLs have [EnableCors] set and indeed - whenstore.load is called with the following:

store.load({ params: { id: pcid }, callback: function (records, options, success) { //do something }});I can see the request coming into the API and returning the correct data!
Does anyone have any clue what the heck ExtJs might be doing here? I have been banging my head against the wall all day :(

wayne-oo
27 Aug 2013, 10:34 AM
I can't edit this thread to sort out the formatting - here is the q on SO:

http://stackoverflow.com/questions/18471455/extjs-store-load-with-id-causes-cors-error

wayne-oo
27 Aug 2013, 11:20 PM
In fact it doesn't even need an ID - calling load causes a cors error even when there is data loading on the same page from the same domain!!

evant
27 Aug 2013, 11:50 PM
It must be some kind of setting with either your web server configuration or your server stack, Ext won't attempt to send off a CORS request unless you explicitly ask for it.