zoukankan      html  css  js  c++  java
  • js的document.forms[0].submit()

    解释:将form表单提交到form里面的action属性指向的地方

    • document.forms:表示获取当前页面的所有表单

    • document.forms[0]:表示获取当前页面的第一个表单
      document.forms[0].submit()

    • document.forms['exportServlet']:表示获取当前页面的name="exportServlet"的表单
      document.forms['exportServlet'].submit()

    • submit()表示提交函数

    举例(支付宝支付功能)

    zfbpay(){
        let config={
            headers:{
                "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8"
            }
        }
        let params=new URLSearchParams()
        params.append('money',this.moneyAmount)
        params.append('ispc',2)
        this.$axios.post(`${common.orderApi}/amstc/userRechargeAccountByAliPay`,params,config).then(res=>{
            if(res.data.code==200){
                let divbody=document.createElement('div')
                divbody.innerHTML=res.data.data   //接口返回的data是一个页面,这里将其添加进新的div
                document.body.appendChild(divbody)
                document.forms[0].submit()   //提交表单
            }
        }).catch(err=>{})
    },
    
  • 相关阅读:
    Multithread 之 synchronous
    【转】windows exe文件加载
    Transparent 之 SetLayeredWindowAttributes
    任意目录运行vs2005 tools
    【转】volatile
    Qt1命令行编译
    初识Qt
    typedef使用一
    Qthello
    源文件包含源文件
  • 原文地址:https://www.cnblogs.com/huihuihero/p/12015106.html
Copyright © 2011-2022 走看看