我遇到了使用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"
});
下面是我在NewCustomersVerifyContoller.js上的onConfirmclick函数调用按钮
onConfirmclick: function(me, e, eOpts) {
var jsonData = {};
jsonData.contactId = this.view.down('#oidgafi').getValue();
jsonData.screeningId = this.view.down('#didgafi').getValue();
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 - 错误 reportH1 {字体-family:宋体,Arial字体,无衬线;颜色:白色;背景色:#525D76;字体大小:的22px;} H2 {字体-family:宋体,Arial字体,无衬线;颜色:白色;背景色:#525D76;字体大小:16px的;} H3 {字体-family:宋体,Arial字体,无衬线;颜色:白色;背景色:#525D76;字体大小:14px的;} 身体 {字体-family:宋体,Arial字体,无衬线;颜色:黑色;背景色:白色;} 乙 {font-family:Tahoma,Arial,sans-serif;颜色:白色;背景颜色:#525D76;} P {字体-family:宋体,Arial字体,无衬线;背景:白色;颜色:黑色;字体大小:12px的;}甲 {color:black;} A.name {color:black;}。line {height:1px; background-color:#525D76; border:none;}
HTTP状态400 -
类型状态报告
消息
描述客户发送的请求是 语法不正确。
Apache 的Tomcat / 8.0.21
答案 0 :(得分:0)
Ajax成功或失败功能出错。您正在尝试解码从您的控制器(或中间层服务器)传递的无效json。您需要在解码任何字符串之前控制响应。 只需在Ext.decode()之前添加控制台日志。并在此处发布回复。这将解决您的问题。
答案 1 :(得分:0)
感谢您的支持。
我已将变量 occupationRisk 声明为** occupHit **。 这就是问题......现在已经解决了。