1

私は単純なモデルを持っています:

Ext.define('MovieModel', {
        extend : 'Ext.data.Model',
        fields : [ {
            name : 'Title',
            mapping : '@title',
            type : 'string'
        } ],

        proxy : {
            type : 'ajax',
            url : 'http://www.imdbapi.com/?r=xml&plot=full',
            method : 'GET',
            reader : {
                type : 'xml',
                record : 'movie'
            }
        }
    });

ただし、このコードはクロスドメインポリシーをサポートしていません。どうすれば解決できますか?

4

1 に答える 1

1

まず、r=xmlparam を削除します。ajaxプロキシの代わりに次のものを使用しますjsonp

    proxy : {
        type : 'jsonp',
        url : 'http://www.imdbapi.com/?plot=full',
        // jsonp uses its special method for retrieving data. So no need for the following row
        //method : 'GET',
        reader : {
            type : 'json',
            // the record param is used when data is nested construction
            // which is not true in your case
            //record : 'movie'
        }
    }

これがデモです。

于 2011-11-02T15:25:42.257 に答える