Javascript Extjs4-表单提交总是返回失败
我正在使用Javascript Extjs4-表单提交总是返回失败,javascript,forms,extjs,extjs4,Javascript,Forms,Extjs,Extjs4,我正在使用extjs4表单提交一个excel文件,但即使请求成功,它也会注册失败。表单是什么。提交功能希望看到什么 表格 xtype: 'form', name: 'upload_form', items: [{ text: 'File Upload', xtype: 'fileuploadfield', name: 'upload_btn', buttonOnly: true, hideLabel: true, allo
extjs4
表单提交一个excel文件,但即使请求成功,它也会注册失败。表单是什么。提交功能希望看到什么
表格
xtype: 'form',
name: 'upload_form',
items: [{
text: 'File Upload',
xtype: 'fileuploadfield',
name: 'upload_btn',
buttonOnly: true,
hideLabel: true,
allowBlank: false,
clearOnSubmit: false
}]
控制器
'filter fileuploadfield[name="upload_btn"]': {
change: this.UploadClick
}
...
UploadClick: function (vb, s) {
var controller = this,
form = controller.getUploadForm();
if (form.isValid()) {
form.submit({
url: '/upload',
waitMsg: 'Uploading your csv...',
success: function (fp, o) {
Ext.Msg.show({
title: 'Upload Complete',
msg: o.response.responseText,
icon: 'save-success',
buttons: Ext.Msg.OK
});
},
failure: function (fp, o) {
Ext.Msg.show({
title: 'Upload Error',
msg: o.response.responseText,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
}
});
}
}
Java返回
Response.ResponseBuilder builder;
...
builder = Response.ok(null);
return builder.build();
您需要在响应中附加参数success
:
例如:
如文件所示:
您需要附加参数success
作为响应:
例如:
如文件所示:
不要发送null
…而是发送所需的JSON
以及适当的内容类型标题:
String json = "{\"success\": true}";
return Response.ok(json, MediaType.APPLICATION_JSON).build();
不要发送null
…但应发送JSON
以及适当的内容类型标题:
String json = "{\"success\": true}";
return Response.ok(json, MediaType.APPLICATION_JSON).build();