如何将表单元素传递给 Ext AJAX 请求
How to pass the form element to Ext AJAX request
我在将表单传递给 ExtJS6 AJAX 请求时遇到问题。
docs 状态:
form : Ext.dom.Element / HTMLElement / String
The form Element or the id of the form to pull parameters from.
作用域不是问题,这里引用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() 和这个。
无论我尝试什么,我都会收到此错误:
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);
}
});
}
})
}
});
我在将表单传递给 ExtJS6 AJAX 请求时遇到问题。 docs 状态:
form : Ext.dom.Element / HTMLElement / String
The form Element or the id of the form to pull parameters from.
作用域不是问题,这里引用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() 和这个。
无论我尝试什么,我都会收到此错误:
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);
}
});
}
})
}
});