我在将表单传递给ExtJS6 AJAX请求时遇到问题。docs状态:
form:Ext.dom.Element / HTMLElement / String
要从中提取参数的表单元素或表单的ID。
范围不是问题,此引用为Ext.form.Panel
我的代码是:
Ext.Ajax.request({
scope: this,
method: 'POST',
url: 'someurl',
form: this.getEl(),
isUpload: true,
success: this.someSuccessFunction
failure: this.someFailureFunction
});
我也尝试过this.getId(),this.getForm()。getId()和this。
无论如何,都会出现此错误:
Uncaught TypeError: form.submit is not a function
有人知道我的代码有什么问题吗?
Ext.form.Panel不包含表单标签。在真正的html表单中使用此功能。查看以下示例的已发送请求:fiddle
Ext.application({
name: 'Fiddle',
launch: function () {
Ext.create('Ext.button.Button', {
text: "Submit",
renderTo: Ext.getBody(),
handler: function () {
Ext.Ajax.request({
url: 'user.json',
form: Ext.fly('userForm').dom,
success: function (response, opts) {
var obj = Ext.decode(response.responseText); // THIS IS A REAL HTML FORM
console.dir(obj);
},
failure: function (response, opts) {
console.log('server-side failure with status code ' + response.status);
}
});
}
})
}
});