Results 1 to 4 of 4

Thread: Cross domain Problem with Ajax

  1. #1
    Sencha Premium Member
    Join Date
    Dec 2011
    Posts
    94
    Answers
    1
    Vote Rating
    0
      0  

    Default Cross domain Problem with Ajax

    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.
    Code:
            Ext.create('Ext.data.Store', {
                storeId:'Users',
                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,
    Sridhar

  2. #2
    Sencha User
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    347
    Vote Rating
    119
      0  

    Default

    Try using jsonp proxy instead of ajax proxy

  3. #3
    Sencha Premium Member
    Join Date
    Dec 2011
    Posts
    94
    Answers
    1
    Vote Rating
    0
      0  

    Default

    Thanks.

    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.

    Regards,
    Sridhar

  4. #4
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,791
    Answers
    585
    Vote Rating
    394
      0  

    Default

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •