简体   繁体   中英

How load xml data from another domain

I need load some xml data from service in another domain. If i use ajax request i get "Origin null is not allowed by Access-Control-Allow-Origin.". I tried use Store with scriptag proxy and xml reader, but i get Uncaught SyntaxError: Unexpected token < v

var myStore = new Ext.data.Store({
        model: 'myModel',
        proxy: {
            type: 'scripttag',
            url : url,
            reader: {
                type: 'xml',
                root: 'users'
            }
        },
        autoLoad: true
    });

Question: how load xml data from another domain using sencha or other javascript library.

1) In case you have access to backend you can enable cross-origing resource sharing(CORS): how to do it . It will allow you to get xml data from another domain.

2) If not you can use YQL(but it looks like dirty hack) : here

3) Anyway when you will run your application on mobile device this problem should go away.

4) If you want to find solution to test your application on desktop browser I suggest you to use chrome. Because there is a way to disable this security restriction:

chrome.exe --disable-web-security

5) And the last tip is to find JSON services because JSONP requests don't have such problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM