PDA

View Full Version : Problem with DataStore / JsonReader / OPTIONS-Request



alexp83
29 Apr 2010, 4:56 AM
Hey everyone,

I'm just making my first steps with extjs and now I'm having a problem setting up a Datastore which gets his data from a URL with Json formatted content.

My code looks like this:

var ds = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'http://www.xyz.de/test.htm',
method: 'GET'
}),

reader: new Ext.data.JsonReader({
root: 'results',
totalProperty: 'total',
fields: [{name: 'col1', mapping: 'col1'},
{name: 'col2', mapping: 'col2'}
]
})
});


ds.load({
// store loading is asynchronous, use a load listener or callback to handle results
callback: function(){
Ext.Msg.show({
title: 'Store Load Callback',
msg: 'store was loaded, data available for processing',
modal: false,
icon: Ext.Msg.INFO,
buttons: Ext.Msg.OK
});
}
});

When I debug the load-call in Firebug I see that there is a HTTP OPTIONS-Request to the URL with an empty answer. This is kind of weird as in all examples I saw the Request type was either GET or POST. The URL works if I call it in a browser by myself.

Does anyone has an idea what the problem could be? Tried to find something on google, but was not successful.

Thanks a lot for your help.

Best regards,

Alex

Condor
29 Apr 2010, 5:53 AM
You can't use a HttpProxy to connect to a different domain.

You can only do that with a ScriptTagProxy (if the server supports the script tag syntax).

Animal
29 Apr 2010, 7:43 AM
It's FF asking what it's allowed to do on that domain.

https://developer.mozilla.org/En/HTTP_access_control

Both Chome and FF can do cross domain XHR.