PDA

View Full Version : Cross-Domain JSON Accept header



sbonnick
8 Feb 2011, 6:45 AM
Hi,

Im currently trying connect to a cross-domain server returning JSON information. Im running into problems however since the site returns either xml or json based on the accept header it recives. Currently Im using the following command but im getting XML back and not JSON:



Ext.onReady(function() {
Ext.util.JSONP.request({
url: 'http://someURL.com/httpAuth/app/rest/projects',
callbackKey: 'json',
params: {},
callback: 'callme'
//scope: cfg.scope || window
});
}

function callme(data) {
Ext.getCmp('content').update(dump(data));
}


problem is that when using the chrome javascript debugger, it reports that the return information is XML and then of course the JSON command cannot be parsed. So my question is can I specify the accept header somewhere?

based on server application API:
"support both "application/xml" and "application/json". Supply appropriate "Accept" header in the request to get necessary response type."


Also, as a secondary question, is there a way to pass basic authentication information?