当前位置: 首页 > 知识库问答 >
问题:

未捕获的错误:您正在尝试解码无效的JSON字符串

栾弘新
2023-03-14

我遇到了使用Java存储数据的EXT js代码的问题。下面是我的代码。有谁能帮帮我吗。

下面是我的NewCustomersVerify.js代码:

var myHit = Ext.create('Ext.data.Store',{
    fields:['Id','Name'],
    data:[
        {Id:'0',Name:'No'},
        {Id:'1',Name:'Yes'}
    ]
});
var myRisk = Ext.create('Ext.data.Store',{
    fields:['Id','Name'],
    data:[
        {Id:'0',Name:'Low'},
        {Id:'1',Name:'High'}
    ]
});

Ext.define('Test.test.web.test.view.test.NewCustomersVerify', {
     "xtype": "newCustomersVerify",
     "items": [{
          "xtype": "panel",
          "items": [{
               "xtype": "panel",
               "items": [{
                   "xtype": "displayfield",
                   "fieldLabel": "Name :",
                   "margin": 5,
                   "value": "TEXT",
                   "name": "customerName",
                   "title": "Customer Name",
                   "itemId": "lnajnbi",     "bind": "{customerName}"
              },{
                  "xtype": "displayfield",
                  "fieldLabel": "Nationality :",
                  "margin": 5,
                  "value": "TEXT",
                  "name": "nationality",
                  "title": "Nationality",
                  "itemId": "lnbjnbi",     "bind": "{nationality}"
             },{
                 "xtype": "displayfield",
                 "fieldLabel": "UniqueId No :",
                 "margin": 5,
                 "value": "TEXT",
                 "name": "uniqueIdNo",
                 "title": "UniqueId No",
                 "itemId": "lncjnbi",     "bind": "{uniqueIdNo}"
            },{
                    "xtype": "hiddenfield",
                    "fieldLabel": "HiddenText",
                    "bindable": "contactId",
                    "margin": 5,
                    "name": "contactId",
                    "title": "HiddenText",
                    "itemId": "oidgafi",
                    "bind": "{contactId}"
               },{
                   "xtype": "hiddenfield",
                   "fieldLabel": "HiddenText",
                   "bindable": "screeningId",
                   "margin": 5,
                   "name": "screeningId",
                   "title": "HiddenText",
                   "itemId": "didgafi",
                   "bind": "{screeningId}"
              }],
               "layout": "vbox",
               "autoScroll": true,
               "margin": 5,
               "columnWidth": 0.5,
               "itemId": "cieadni",
               "dockedItems": []
          }, {
              "xtype": "panel",
              "items": [
              {
               "xtype": "combo",
               "fieldLabel": "Was there a verify hit?",
               "name": "screeningHit",
               "margin": 5,
               "bindable": "screeningHit",
               "title": "Was there a verify hit?",
               "columnWidth": 0.5,
               "width": "100",
               "labelAlign": "left",
               "itemId": "kbfmjgi",
               displayField:'Name',
               valueField:'Id',
               queryMode:'local',
               store: myHit,

          }, {
              "xtype": "combo",
              "fieldLabel": "Country Risk (Nationality)",
              "name": "countryRisk",
              "margin": 5,
              "bindable": "countryRisk",
              "title": "Country Risk (Nationality)",
              "columnWidth": 0.5,
              "width": "100",
              "labelAlign": "left",
              "itemId": "kbgajgi",
              displayField:'Name',
              valueField:'Id',
              queryMode:'local',
              store: myRisk
         }, {
             "xtype": "combo",
             "fieldLabel": "Occupation Risk",
             "name": "occupationRisk",
             "margin": 5,
             "bindable": "occupationRisk",
             "title": "Occupation Risk",
             "columnWidth": 0.5,
             "width": "100",
             "labelAlign": "left",
             "itemId": "kbaajgi",
             displayField:'Name',
             valueField:'Id',             
             queryMode:'local',
             store: myRisk
        }, {
                "xtype" : "filefield",
                "fieldLabel": "Upload evidence of verify (Screenshot from the verify portal)",
                "msgTarget" : "side",
                "allowBlank" : "false",
                "buttonOnly" : "true",
                "margin" : 5,
                "name" : "uploadFile",
                buttonConfig : {
                    "text" : "Upload",
                    "icon" : "images/cloud/upload.png",
                },
                listeners : {
                    change :"uploadFile"
                }
            }],
         "layout": "vbox",
         "autoScroll": true,
         "margin": 5,
         "columnWidth": 0.5,         
         "itemId": "nehbeki",
         "dockedItems": []
    }],
          "layout": "column",
          "autoScroll": true,
          "border": true,
          "margin": 5,
          "itemId": "gjihcpi",
          "dockedItems": [{
               "xtype": "toolbar",
               "dock": "bottom",
               "ui": "footer",
               "isToolBar": true,
               "isDockedItem": true,
               "items": [{
                    "xtype": "tbfill",
                    "itemId": "hajhegi"
               }, 
/*               {
                    "xtype": "button",
                    "name": "cancel",
                    "text": "Cancel",
                    "margin": 5,
                    "isResetButton": true,
                    "itemId": "bbkmkmi",
                    "listeners": {
                         "click": "oncancelclick"
                    }
               },*/ 
               {
                    "xtype": "button",
                    "name": "Confirm",
                    "text": "Confirm",
                    "margin": 5,
                    "itemId": "celbgji",
                    "listeners": {
                         "click": "onConfirmclick"
                    }
               }],
               "columnWidth": 0.5,
               "itemId": "lfmepni",
               "dockedItems": []
          }]
     }],
     "border": true,
     "autoScroll": false,
//     "title": "New Customer Verify",
     "margin": 5,
     "itemId": "dinfmki",
     "dockedItems": [],
     "extend": "Ext.form.Panel",
     "listeners": {
          "afterrender": "onafterrender",
          "scope": "controller"
     },
     "requires": ["Test.test.web.test.controller.test.NewCustomersVerifyController", "Test.test.shared.test.viewmodel.test.NewCustomersVerifyViewModel", "Test.test.shared.test.model.test.NewCustomersVerifyModel"],
     "viewModel": "NewCustomersVerifyViewModel",
     "controller": "NewCustomersVerifyController"
});
onConfirmclick: function(me, e, eOpts) {
      var jsonData = {};
      jsonData.contactId = this.view.down('#oidgafi').getValue();
      jsonData.screeningId = this.view.down('#didgafi').getValue();
      html" target="_blank">jsonData.screeningHit = this.view.down('#kbfmjgi').getValue();
      jsonData.countryHit = this.view.down('#kbgajgi').getValue();
      jsonData.occupationHit = this.view.down('#kbaajgi').getValue();
      var scope = this.getView();
        Ext.MessageBox.show({
            msg : 'Saving data...',
            progressText : 'Saving...',
            width : 300,
            wait : true,
            waitConfig : {
                interval : 200
            }
        });
      Ext.Ajax.request({              
           url: 'secure/NewCustomersVerifyServiceWS/respond',
           method: 'POST',
           sender: scope,
           jsonData: jsonData,
           me: me,
           success: function(response, scope) {
                Ext.MessageBox.hide();
                responseData = Ext.JSON.decode(response.responseText);
                Ext.Msg.alert('Server Response', responseData.response.message);
                win = scope.sender.up();
                win.reportViewController.queryCriteria.controller.filterData(win.searchButtonRef);
                win.close();
           },
           failure: function(response, scope) {
                Ext.MessageBox.hide();
                responseData = Ext.JSON.decode(response.responseText);
                Ext.Msg.alert('Server Response', responseData.response.message);
           }
      }, scope);
 }

下面是我在浏览器控制台上遇到的错误。

[E]ext.JSON.decode():您正在尝试解码无效的JSON字符串:Apache Tomcat/8.0.21-Error reportH1{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525d76;font-size:22px;}H2{font-family:Tahoma,Arial,Sans-serif;color:white;background-color:#525d76;font-size:16px;}H3{font-family:Tahoma,Arial,Sans-serif;color:white;background-color:#525d76;font-size:14px;}正文{font-family:Tahoma,Arial,Sans-serif;color:black;background-color:white;}B{font-family:Tahoma,Arial,Sans-serif;color:white;background-color:#525d76;}P{font-family:Tahoma,Arial,Sans-serif;background:white;color:black;font-size:12px;}A{color:black;}A.name{color:black;}.line{height:1px;background-color:#525d76;border:none;}

类型状态报告

消息

Description客户端发送的请求语法不正确。

共有1个答案

莘俊能
2023-03-14

Ajax成功或失败函数出错。您正在尝试解码从控制器(或中间层服务器)传递的无效json。您需要在解码任何字符串之前控制台响应。只需在ext.decode()之前添加控制台日志。并在此发布响应。那会解决你的问题。

 类似资料:
  • 问题内容: 我想知道是否有一种方法可以解码类似JSON的字符串。 我得到了字符串: 这不是有效的JSON字符串,因此我无法直接使用python API对其进行解码。Python将仅接受字符串化的JSON字符串,例如: 其中属性被引用为字符串。 问题答案: 使用demjson模块,该模块具有在非严格模式下解码的能力。

  • 我有以下代码。 然而,它没有捕捉到所有的错误,我仍然得到“throw er//未处理的“错误”事件。 这是为什么呢? 例如,直到我添加了一个特定的错误处理程序,它才捕获parse()函数中的错误。即使不添加,我的try/catch是否应该捕获此错误? 提前致谢!

  • 问题内容: 我用来解码以下json字符串。 这是一个用Python编写的演示: 解码器将抛出: 如何应对呢?预期的输出是: 问题答案: “ \ s”不是有效的JSON转义字符串。 根据json.org,仅以下转义有效 \“ \\ / \ b \F \ n \ r \ t \ u 四十六进制数字

  • 问题内容: 这是我的Javascript代码 这是我的HTML 我遇到错误 错误:无法在“窗口”上执行“ atob”:要解码的字符串未正确编码 问题答案: 我有我的问题。这对于其他用户使用javascript(AnguarJs)保存图像和压缩图像应该会有所帮助。 我正在流动此链接以压缩图像 Github https://github.com/oukan/angular-image- compres

  • 问题内容: 我使用Golang HTTP请求获取json输出,如下所示。我尝试访问的Web服务是Micrsoft Translator https://msdn.microsoft.com/en- us/library/dn876735.aspx 我收到一个错误 因此,我尝试打印as字符串,它显示: 看来数据没有任何问题,所以我尝试通过创建相同的值 我发现原始数据可能有问题,因此我尝试比较两种格式

  • 问题内容: 我正在尝试使用java解析JSON字符串。我不知道该怎么做,我在互联网上搜索了很多内容,但有了一些主意。有了我,我有构建代码,但它不起作用。当尝试执行我的代码时,它将引发错误。我无法解决错误。 看到下面是我的代码: 我的JSON字符串在该文件中: 当我执行代码时,它会引发如下错误: 请帮助我解决这个问题,在此先感谢 问题答案: 您的json在Java中解析错误。在Java中,最大值为