我的问题是当我将Store中的类型更改为ajax时。 我的应用程序中的商店看起来像这样:
var urlRoot = 'data?model=Operation&method=';
Ext.define('BookApp.store.BookStore', {
extend: 'Ext.data.Store',
model: 'BookApp.model.Book',
autoLoad: true,
storeId: 'BookStore',
proxy: {
type: 'jsonp',
noCache: false,
api: {
create: urlRoot + 'Create',
read: urlRoot + 'Read',
update: urlRoot + 'Update',
destroy: urlRoot + 'Destroy'
},
reader: {
type: 'json',
metaProperty: 'meta',
rootProperty: 'data',
idProperty: 'id',
totalProperty: 'meta.total',
successProperty: 'meta.success'
},
writer: {
type: 'json',
encode: true,
writeAllFields: true,
rootProperty: 'data',
allowSingle: false
}
}
});
当我将商店类型更改为ajax
.....
proxy: {
type: 'ajax',
.....
然后,当我下载应用程序时,出现错误500(内部服务器错误) 我知道从运行我的应用程序的另一个域中加载数据需要jsonp类型,但是我将整个应用程序和数据库包括在同一本地计算机上,因此我设置了ajax的类型。但是使用这种类型会出现问题。
在后端,答案如下:
...
# Form the answer
dict_out= {"data" : list, "meta": { "success": "true", "msg": "", "total": str(count) }}
# Translate it into the format Json
jsonFormat = json.dumps(dict_out)
# Add to the answer callback
read_out = dict['callback'] +'(' + jsonFormat + ')'
return HttpResponse(read_out)
....
为什么会出现此问题?
谢谢