Sencha touch 使用Sencha Touch 2无法进行跨域请求

Sencha touch 使用Sencha Touch 2无法进行跨域请求,sencha-touch,sencha-touch-2,Sencha Touch,Sencha Touch 2,我有一个显示一些文章的应用程序。该应用程序在本地主机中的Wamp上运行良好。我已将数据库管理上载到其他服务器。我已经在JSONP中配置了我的ArticleStore.js,但是当我运行应用程序时,控制台中会出现以下错误: Resource interpreted as Script but transferred with MIME type text/html: "http://[ip_address]:[port]/totos?_dc=1372152920457&keyword=&a

我有一个显示一些文章的应用程序。该应用程序在本地主机中的Wamp上运行良好。我已将数据库管理上载到其他服务器。我已经在JSONP中配置了我的ArticleStore.js,但是当我运行应用程序时,控制台中会出现以下错误:

Resource interpreted as Script but transferred with MIME type text/html: "http://[ip_address]:[port]/totos?_dc=1372152920457&keyword=&page=1&start=0&limit=25&callback=Ext.data.JsonP.callback1"
以及:

当我点击上面的url时,我将被重定向到显示以下内容的视图:

{"articles_list":[{"id":"28","title":"Prixtel dope son service client avec le forfait Sumo"}],"total":1}
Ext.define("MyApp.store.ArticleListStore",
{
    extend: "Ext.data.Store",    
    requires: ["MyApp.model.ArticleModel","Ext.data.proxy.JsonP"],
    config: {
    model: "MyApp.model.ArticleModel",
    proxy: {
        type: 'jsonp',
        model: "MyApp.model.ArticleModel",
        url: "http://62.23.96.124:81/totos",
        },
        reader: {
            type: "json",
            rootProperty: "articles_list",
            totalProperty: "total"
        },
    },
        autoLoad: true
    }
});
为了简单起见,我测试了只显示一篇文章的标题。下面是我在“totos:1”上clic时对第1行的JSON响应:

{"articles_list":[{"id":"28","title":"Prixtel dope son service client avec le forfait Sumo"}],"total":1}
以下是我的ArticleStore.js内容:

{"articles_list":[{"id":"28","title":"Prixtel dope son service client avec le forfait Sumo"}],"total":1}
Ext.define("MyApp.store.ArticleListStore",
{
    extend: "Ext.data.Store",    
    requires: ["MyApp.model.ArticleModel","Ext.data.proxy.JsonP"],
    config: {
    model: "MyApp.model.ArticleModel",
    proxy: {
        type: 'jsonp',
        model: "MyApp.model.ArticleModel",
        url: "http://62.23.96.124:81/totos",
        },
        reader: {
            type: "json",
            rootProperty: "articles_list",
            totalProperty: "total"
        },
    },
        autoLoad: true
    }
});
当我直接在Wamp服务器上的localhost中启动我的resquest时,我的JSON响应具有相同的语法(JSON树架构是相同的)。下面是一个例子:

{"articles_list":[{"id":"384","title":"Skype est disponible sur Windows Phone"}],"total":1}
我看不出这两种回答之间有什么区别。但是,我有一个“意外令牌”错误!。正如您所看到的,对于这两个示例,两个节点“articles_list”和“total”在JSON树中的位置相同。我不明白为什么会有语法错误。我真的迷路了。有人能帮我吗?
非常感谢您的帮助。

您的服务器没有正确格式化JSON-p的响应。JSON-p基本上需要将您的响应嵌入到一个函数中,该函数由代理的
callbackKey
属性指定:

proxy: {
    type: 'jsonp',
    url : "http://62.23.96.124:81/totos",
    callbackKey: 'myCallbackKey'
}
然后,在服务器上,需要使用该参数包装响应:

myCallbackKey({
    "articles_list": [
        {
            "id":"28",
            "title":"Prixtel dope son service client avec le forfait Sumo"
        }
    ],
    "total":1
})
您可以从以下文档了解更多信息:。 您还想进一步了解JSON-P的用途以及它的工作原理。请在此处查看更多信息: