【问题标题】:How to call web services using json proxy in sencha touch?如何在 sencha touch 中使用 json 代理调用 Web 服务?
【发布时间】:2012-05-13 19:44:39
【问题描述】:

我也是 sencha touch 和 Web 服务的新手。我有一个 json 文件,我使用它来填充我的屏幕,如下所示:

proxy:{
       type:'ajax',
       url:'data/messages.json',

        reader:
        {
            type:'json',
            rootProperty:'alerts'
        }
    }

这对我来说很好。但是当我尝试做同样的网络服务时,我在控制台上得到了这个:

选项 http://{server}/aosmobile/alerts?_dc=1336122076647&page=1&start=0&limit=25 404(未找到)

XMLHttpRequest 无法加载 http://{server}/aosmobile/alerts?_dc=1336122076647&page=1&start=0&limit=25。 来源http://localhost:8080 不允许 访问控制允许来源。

我也是用这个方法实现的:

proxy:{

        type:'rest',
        url:'http://{server}/aosmobile/alerts',
        headers: {                
            'Accept' : 'application/json'                 
        },
        reader:
        {
            type:'json',
            rootProperty:'alerts'
        }
    }

url 已部署。请帮忙。

【问题讨论】:

  • 同样常见的Origin http://localhost:8080 is not allowed by Access-Control-Allow-Origin. 错误..查看其他 SO 帖子的解决方案..

标签: json web-services proxy sencha-touch


【解决方案1】:

您似乎正在执行跨域请求。以下代理定义可能会有所帮助:

proxy:{
    type:'scripttag',
    url:'http://{server}/aosmobile/alerts',
    reader:
    {
        type:'jsonp',
        rootProperty:'alerts'
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-09-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多