View Full Version : Cross domain Problem with Ajax

1 Mar 2012, 11:01 PM
Hi All,

I am trying contact webservice / servlet from other domain by using Store object with Ajax Proxy. If I run this application with Internet Explorer, it will say "Access denied". If I try the same with Firefox, it will give the server response code as '302'.

Could you please help to resolve this.

Ext.create('Ext.data.Store', {
fields:['rno', 'name', 'age'],
proxy: {
type: 'ajax',
method: 'POST',
url: 'http://serverurlwithjava:8080/ExtJSPOC/GetUserDetails',
reader: {
type: 'xml',
root: 'data',
record: 'record'
autoLoad: true

var panel = Ext.create('Ext.grid.Panel', {
title: 'Browser',
store: Ext.data.StoreManager.lookup('Users'),
columns: [
{ header: 'R. No', dataIndex: 'rno' },
{ header: 'Name', dataIndex: 'name', flex: 1 },
{ header: 'Age', dataIndex: 'age' }
height: '100%',
width: '100%'

Thanks in Advance,

1 Mar 2012, 11:44 PM
Try using jsonp (http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.proxy.JsonP)proxy instead of ajax proxy

2 Mar 2012, 12:39 AM

But, I can't use json, my server side api will give only in XML format, not in JSON format.

Could you please elaborate your point. Otherwise, give me some other way to do.

It will be helpful for me.


2 Mar 2012, 6:06 AM
There are highly restrictive limitations on what a browser will let you do cross-domain.

If you want to access an XML source via POST on a different domain then CORS (cross-origin resource sharing) is your only chance. It isn't supported by all browsers (notably Opera and older IE) but that may be OK depending on your browser requirements.

CORS requires changes to the server's response headers. If you don't have the ability to get the server modified then you can't access it cross-domain. You could remove the cross-origin aspect by proxying through your own server but that may not be viable for other reasons.