Question

I have a simple model:

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'
            }
        }
    });

But this code doesn't support cross domain policy. How could I solve it?

Was it helpful?

Solution

First of all get rid of r=xml param. Instead of ajax proxy use jsonp one:

    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'
        }
    }

Here is demo.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top