我得到了以下服务器响应:
回调({“数据”:{ "id":"13_gnomodotiseis“、"id1":13、”标题“:"5/2009ΓΝΜΔΕΙΣΑΠ2009”、“文本”:"5/2009ΓΝΜΔΕΙΣΑΠ“、”模型“:"gnomodotiseis”、"body":“σίλει.“类型”:“文本”、“历史”:“旧”、"url":"“、"search_tag":"Γνωμοδοτήσεις”、"new_element":"true“}、"dataset":1 })
我有这样的商店定义:
var baseUrl = 'http://localhost:8090/';
Ext.define('Ktimatologio.store.NewSingleBlockStore', {
extend: 'Ext.data.Store',
alias: 'widget.newsingleblockstore',
requires: ['Ktimatologio.model.NewSingleBlockModel'],
model: 'Ktimatologio.model.NewSingleBlockModel',
groupField: 'search_tag',
fields: [
{name:'id', mapping:'id'},
{name:'id1', mapping:'id1'},
{name: 'text', mapping: 'text'},
{name: 'title', mapping: 'title'},
{name: 'fek', mapping: 'fek'},
{name: 'date', mapping: 'date'},
{name: 'descr', mapping: 'description'},
{name: 'model', mapping: 'model'},
{name: 'body', mapping: 'body'},
{name: 'type', mapping: 'type'},
{name: 'history', mapping: 'history'},
{name: 'src', mapping: 'url'},
{name: 'search_tag', mapping: 'search_tag'},
{name: 'new_element', mapping: 'new_element'},
{name: 'new_table', mapping: 'new_table'}
],
autoLoad: true,
proxy: {
//type:'ajax',
type:'jsonp',
url: baseUrl + 'openbd/ktimatologio-final/resources/cfScripts/nea_stoixeia/GetNews.cfc?',
callbackKey: 'callback',
extraParams: {
method: 'jsonP'
},
reader:{
type: 'json',
root: 'data'
}
}
});我在firebug中看到的url:
tag"%2C"direction"%3A"ASC"}]&callback=Ext.data.JsonP.callback2
Firebug给了我错误:"ReferenceError:回调未定义“
我的问题是:
Ext.data.JsonP.callback2从哪里弹出的url?
我在这里错过了什么?Extjs4.1中的jsonP是如何工作的?
这件事我真的需要帮助。
提前谢谢你,
汤姆
希腊
发布于 2012-08-20 18:05:28
您在响应中使用了错误的函数名。如果您查看请求url,可以看到它正在发送您的响应需要调用的函数名,并且需要在响应数据:&callback=Ext.data.JsonP.callback2中使用它,因此响应应该调用函数Ext.data.JsonP.callback2,而不是简单的回调。因此,在您的示例中,服务器应该将其作为响应返回:
Ext.data.JsonP.callback2({ "data": [ { "id": "13_gnomodotiseis", "id1": 13, "title": "5/2009 ΓΝΜΔ ΕΙΣΑΠ 2009", "text": "5/2009 ΓΝΜΔ ΕΙΣΑΠ ", "model": "gnomodotiseis", "body": "σίλει...", "type": "text", "history": "old", "url": "", "search_tag": "Γνωμοδοτήσεις", "new_element": "true" } ], "dataset": 1 })这是因为callback=Ext.data.JsonP.callback2是在请求中发送的。
https://stackoverflow.com/questions/12021947
复制相似问题