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=xml参数。而不是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 回答