gpt4 book ai didi

javascript - Extjs4 - 表单提交总是返回失败

转载 作者:行者123 更新时间:2023-12-01 01:08:57 26 4
gpt4 key购买 nike

我正在使用 ExtJS 4 表单提交 Excel 文件,但即使请求成功,它也会注册失败。 form.submit 函数期望看到什么?

Console

表单

xtype: 'form',
name: 'upload_form',
items: [{
text: 'File Upload',
xtype: 'fileuploadfield',
name: 'upload_btn',
buttonOnly: true,
hideLabel: true,
allowBlank: false,
clearOnSubmit: false
}]

Controller

'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();

最佳答案

不要发送null Response ...但是预期的 JSON 以及正确的内容类型 header :

String json = "{\"success\": true}";
return Response.ok(json, MediaType.APPLICATION_JSON).build();

关于javascript - Extjs4 - 表单提交总是返回失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55340769/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com