View Full Version : How to load data from cross-domain server into store using proxy extjs4

31 Mar 2014, 5:41 AM
Hi guys, i am stuck with this problem, so if you could help me?


No one answered me yet.

2 Apr 2014, 10:48 AM

Try setting Ext.Ajax.cors = true; before your application kicks off.

You'll also need to set up CORS on the remote server as well. A resource I've seen come in handy for folks is:

2 Apr 2014, 11:43 AM
Do you want to use CORS or JSON-P? Your current config seems to be a mix of the two.

This line implies you're trying to use CORS. It prevents ExtJS adding a custom header, which would force CORS into a pre-flight OPTIONS request:

Ext.Ajax.useDefaultXhrHeader = false;

Similarly, the data returned from your server is JSON, not JSON-P.

However, this line configures a JSON-P proxy:

type: 'jsonp'

If you want to use CORS you'd use an Ajax proxy.

Either way you'll need to write your server to match.

3 Apr 2014, 2:35 AM
Hey guys, this helped me! Thanks!

Ext.Ajax.cors = true; is set by default so i didn't have to set it by myself, but i added this code in my server:

app.all('*', function(req, res, next) { res.header("Access-Control-Allow-Origin", "*"); res.header("Access-Control-Allow-Headers", "X-Requested-With"); next(); });

and switch to
type: 'ajax', instead of jsonp