首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >ExtJs 4-跨域策略

ExtJs 4-跨域策略
EN

Stack Overflow用户
提问于 2011-11-02 16:56:00
回答 1查看 3.7K关注 0票数 1

我有一个简单的模型:

代码语言:javascript
运行
复制
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'
            }
        }
    });

但此代码不支持跨域策略。我该怎么解决它呢?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-11-02 23:25:42

首先去掉r=xml参数。使用jsonp one而不是ajax代理:

代码语言:javascript
运行
复制
    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'
        }
    }

这是demo

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7977730

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档