how to retrieve xml from a remote server in SenCha Touch

纵然是瞬间 提交于 2019-12-13 21:00:26

问题


Update:

Hi, I do not think my question is same as the mentioned question, there are 2 reasons:

  1. that question is asking about how to overcome the CORS problem and we all know that from a website, you cannot retrieve data from another website(B) which has different domain unless B has specifically configured its website to allow other to access its data. But in my case, the Cordova/SenCha Touch generated app doesn't have the http protocol when requesting, so it's not the same problem.

  2. I want to know how to do the ajax call in SenCha Touch, but don't know where to put in the ajax call code; but in that post/question developers can put that ajax call code in anywhere which is not my case.

Please reconsider your request about closing down my question.

Thank you


I need to retrieve data which is in xml format from a remote server. The data is opened to the public, so no restrictions.

Here is my code :

Ext.define('myApp.store.configStore', {
    extend: 'Ext.data.Store',
    requires: 'myApp.model.Config',
    autoLoad: true,
    storeId: 'ConfigStore',
    proxy: {
        type: 'ajax',
        url: 'http://webtrak.bksv.com/mel/configuration',
        reader: {
            type: 'xml',
            record: 'airport',
            rootProperty: 'config'
        }
    }
});

But I am not able to get anything.

I cannot test it in browsers as the reason:

> "No 'Access-Control-Allow-Origin' header is present on the requested
> resource. Origin 'http://localhost:1991' is therefore not allowed
> access."

But if I test it in mobile phone, then I cannot get any error messages. So which means basically it's really hard to debug the app, I have to reply on guessing all the time which is REALLY PAINFUL!!!!

Can someone post a code example for me? For your convenience, I found a fantastic place to test code:

SenCha Fiddle

I am looking forward to any advice and help.

Thanks in advance.

来源:https://stackoverflow.com/questions/23007336/how-to-retrieve-xml-from-a-remote-server-in-sencha-touch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!