function makeForm(data) {
// 创建一个 form
const tempForm = document.createElement('form')
tempForm.id = 'tempForm'
tempForm.name = 'tempForm'
// 添加到 body 中
document.body.appendChild(tempForm)
// 创建一个用户名输入
const merchantSubId = document.createElement('input')
merchantSubId.type = 'text'
merchantSubId.name = 'merchantSubId'
merchantSubId.value = this.merchantSubId
const BODY = document.createElement('input')
BODY.type = 'text'
BODY.name = 'BODY'
BODY.value = data.BODY
const INFO = document.createElement('input')
INFO.type = 'text'
INFO.name = 'INFO'
INFO.value = data.INFO
const SIGN = document.createElement('input')
SIGN.type = 'text'
SIGN.name = 'SIGN'
SIGN.value = data.SIGN
const CONTENTTYPE = document.createElement('input')
CONTENTTYPE.type = 'text'
CONTENTTYPE.name = 'CONTENTTYPE'
CONTENTTYPE.value = data.CONTENTTYPE
// 将该输入框插入到 form 中
tempForm.appendChild(merchantSubId)
tempForm.appendChild(BODY)
tempForm.appendChild(INFO)
tempForm.appendChild(SIGN)
tempForm.appendChild(CONTENTTYPE)
// form 的提交方式
tempForm.method = 'POST'
// form 提交路径
tempForm.action = data.serverUrl
tempForm.enctype = 'application/x-www-form-urlencoded'
// 对该 form 执行提交
tempForm.submit()
// 删除该 form
document.body.removeChild(tempForm)
}
javascript from 隐性提交表单
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 今天维护别人的项目,被一个layui问题坑了好久,layui的form表单提交form.on(submit)监听,...
- 简单的dialog 表单提交案例 这里碰到一个问题, 错误信息 这里我们只需要把 this.$refs.copyF...