0

リモート サーバーにあるデータ ソースからコンテンツを読み取る必要があります (何も変更するためのアクセス権がありません)。

コンテンツを取得するために何日も試しましたが、うまくいきません。

次に、xml ファイルであるこのデータ ソースをダウンロードし、コードと同じフォルダーに配置して、コード構文の正確性をテストし、コードが機能することを確認しました。

しかし、外部データ リソース (from: url: 'app/store/configuration.xml' から : url: ' http://webtrak.bksv.com/mel/configuration ' ) に戻すと、まだ読み取られますが、返されます。コンテンツなし。

実際のデバイスでアプリをテストしているため、これは CORS の問題が原因ではありません。

ここに私の店とモデルがあります。助けてください

Ext.define('myApp.store.SensorStationStore', {
    extend: 'Ext.data.Store',
    requires: ['myApp.model.SensorStation', 'Ext.data.reader.Xml'],
    config:{
        model: 'myApp.model.SensorStation',
        storeId: 'SensorStore',
        autoLoad: true,
        proxy: {
                 type: 'ajax',
                 url: 'http://webtrak.bksv.com/mel/configuration',
                 //url: 'app/store/configuration.xml',
                 reader: {
                     type: 'xml',
                     record: 'locations',
                     rootProperty: 'nmts'
                 }
              }
           }

        });

Ext.define('myApp.model.SensorStation', {
    extend: 'Ext.data.Model',
    config: {
        fields: [
            {

                name: 'name', 
                type: 'string',
                mapping: '@name'
                //convert: function (value, record) {
                //    Ext.Msg.alert(value,record.raw);
                //    //var nodes = rec.raw.querySelectorAll('');
                //}
            },
            {
                name: 'lat',
                mapping: '@latitude',
                type: 'float'
            },
            {
                name: 'lng',
                mapping: '@longitude',
                type: 'float'
            },
            {
                name: 'locid',
                mapping:'@locid',
                type: 'string'
            }
        ]
    }
});

ありがとうございました。

4

1 に答える 1

2

私は何が問題なのかを突き止めました...私はXMLを扱ったことがないので、ajaxリクエストの応答がどのように見えるかわかりませんが、ストアに次のコードを適用することで、アプリのストアがいっぱいになります(あなたのコード)

コード:

Ext.define('myApp.store.SensorStationStore', {
    extend: 'Ext.data.Store',
    requires: ['myApp.model.SensorStation', 'Ext.data.reader.Xml'],
    config:{
        model: 'myApp.model.SensorStation',
        storeId: 'SensorStore',
        autoLoad: true,
        proxy: {
            type: 'ajax',
            url: 'http://webtrak.bksv.com/mel/configuration',
            //url: 'app/store/configuration.xml',
            reader: {
                type: 'xml',
                record: 'locations',
                rootProperty: 'nmts'
            }
        }
    } });

構成オブジェクトの外部でストア構成を適用しようとしています。乾杯!!

于 2014-04-23T12:25:28.030 に答える