为了账号安全,请及时绑定邮箱和手机立即绑定

如何将表单元素传递给 Ext AJAX 请求

如何将表单元素传递给 Ext AJAX 请求

饮歌长啸 2022-08-27 13:59:09
我在将表单传递给ExtJS6 AJAX请求时遇到问题。文档指出: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有谁知道我的代码有什么问题吗?
查看完整描述

1 回答

?
长风秋雁

TA贡献1757条经验 获得超7个赞

Ext.form.Panel 不包含表单标记。此功能用于真正的html表单。看看下面例子的请求:小提琴


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

                }

            });


        }

    })

}

});


查看完整回答
反对 回复 2022-08-27
  • 1 回答
  • 0 关注
  • 162 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号