0
我有一些麻煩調試此問題並獲得解決方案。ExtJS - 錯誤狀態'ProtoType'爲空或不是對象
我的數據正在返回給我,但當我在'loadexception'函數上放置一個斷點時,它向我拋出TypeError。以下是錯誤:
描述 - 「‘原型’爲空或不是對象」 消息 - 「‘原型’爲空或不是對象」 名稱 - 「類型錯誤」 數 - -2146823281
因此,即使我的數據恢復正確,我的callbox消息框始終會引發錯誤。
V2020.dsPricing = new Ext.data.JsonStore({
proxy: new Ext.data.HttpProxy({
method: 'POST',
url: url,
headers: {"Content-Type": "application/json; charset=utf-8"},
jsonData: Ext.util.JSON.encode({ serviceId: objPricingReturn.serviceId })
}),
reader: PricingJsonReader()
});
V2020.dsPricing.on('loadexception', function(obj, options, response, err) {
Ext.MessageBox.show({
title: 'Error',
msg: url + ' POST method fail...ErrorCode:' + response.status,
buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.ERROR
});
});
V2020.dsPricing.load({
callback: function(records, o, s) {
if (!s) Ext.MessageBox.show({
title: 'Error',
msg: ' Failed to load pricing data',
buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.ERROR
});
}
});
這裏是JsonReader代碼
function PricingJsonReader() {
var pricingReaderObject = new Ext.data.JsonReader({
root: 'GetServicePriceByIdResult.ServicePricing',
fields: [{
name: 'priceId',
type: 'int'
},
{
name: 'serviceId',
type: 'int'
},
{
name: 'price',
type: 'float'
},
{
name: 'startDate',
type: 'date',
dateFormat: 'n/j/Y'
},
{
name: 'endDate',
type: 'date',
dateFormat: 'n/j/Y'
},
{
name: 'updatedBy',
type: 'string'
},
{
name: 'updateDate',
type: 'date',
dateFormat: 'n/j/Y'
}]
})
return pricingReaderObject;
}
響應(我想這是你所要求的東西)
{"GetServicePriceByIdResult":{"ServicePricing":[{"priceId":14,"serviceId":1,"price":70.0000,"startDate":"6\/14\/2010 12:00:00 AM","endDate":"12\/31\/2011 12:00:00 AM","updatedBy":null,"updateDate":null},{"priceId":142,"serviceId":1,"price":70.0000,"startDate":"6\/14\/2010 12:00:00 AM","endDate":"12\/31\/2011 12:00:00 AM","updatedBy":null,"updateDate":null}]}}
真棒。謝謝你的澄清。我沒有意識到它正在創造一個讀者本身。 – PixelMuse 2010-12-09 21:52:04