Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ExtJS-错误状态';原型&x27;是否为null或不是对象_Javascript_Wcf_Extjs - Fatal编程技术网

Javascript ExtJS-错误状态';原型&x27;是否为null或不是对象

Javascript ExtJS-错误状态';原型&x27;是否为null或不是对象,javascript,wcf,extjs,Javascript,Wcf,Extjs,我在调试和获得解决方案时遇到了一些问题 我的数据被正确地返回给我,但当我在“loadexception”函数上设置断点时,它向我抛出了TypeError。以下是错误: 描述-“'prototype'为空或不是对象” 消息-“'prototype'为空或不是对象” 名称-“类型错误” 电话号码--2146823281 因此,即使我的数据恢复正常,我的callbox消息框也总是出现错误 V2020.dsPricing = new Ext.data.JsonStore({ proxy:

我在调试和获得解决方案时遇到了一些问题

我的数据被正确地返回给我,但当我在“loadexception”函数上设置断点时,它向我抛出了TypeError。以下是错误:

描述-“'prototype'为空或不是对象” 消息-“'prototype'为空或不是对象” 名称-“类型错误” 电话号码--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;
    }
回答(我想这就是你想要的)


您正在使用JsonStore&向它传递一个reader对象,但是JsonStore获取JsonReader的配置并创建一个reader本身。您有两种选择:

  • 对于
    V2020.dsPricing
  • 将JsonReader的配置移动到JsonStore&不再将reader传递到JsonStore
  • 解决方案1:

    var url = "http://localhost/r.json"; objPricingReturn = {serviceId:10}; 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; } V2020 = {}; V2020.dsPricing = new Ext.data.Store({ 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 }); } }); 变量url=”http://localhost/r.json"; objPricingReturn={serviceId:10}; 函数PricingJsonReader(){ var pricingReaderObject=new Ext.data.JsonReader({ root:'GetServicePriceByIdResult.ServicePricing', 字段:[{ 名称:“priceId”, 键入:“int” }, { 名称:“serviceId”, 键入:“int” }, { 名称:'价格', 类型:“浮动” }, { 名称:“开始日期”, 键入:“日期”, 日期格式:“n/j/Y” }, { 名称:'endDate', 键入:“日期”, 日期格式:“n/j/Y” }, { 名称:“updatedBy”, 键入:“字符串” }, { 名称:“updateDate”, 键入:“日期”, 日期格式:“n/j/Y” }] }) 返回pricingReaderObject; } V2020={}; V2020.dsPricing=新的Ext.data.Store({ 代理:新Ext.data.HttpProxy({ 方法:“POST”, url:url, 标题:{“内容类型”:“应用程序/json;字符集=utf-8”}, jsonData:Ext.util.JSON.encode({serviceId:objPricingReturn.serviceId}) }), 读者:PricingJsonReader() }); V2020.dsPricing.on('loadexception',函数(obj、选项、响应、错误){ Ext.MessageBox.show({ 标题:“错误”, msg:url+'POST方法失败…错误代码:'+response.status, 按钮:Ext.MessageBox.OK, 图标:Ext.MessageBox.ERROR }); }); V2020.dsPricing.load({ 回调:函数(记录、o、s){ 如果(!s)Ext.MessageBox.show({ 标题:“错误”, msg:'未能加载定价数据', 按钮:Ext.MessageBox.OK, 图标:Ext.MessageBox.ERROR }); } });
    令人惊叹的。谢谢你的澄清。我没意识到这是在创造一个读者。 var url = "http://localhost/r.json"; objPricingReturn = {serviceId:10}; 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; } V2020 = {}; V2020.dsPricing = new Ext.data.Store({ 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 }); } });