zoukankan      html  css  js  c++  java
  • 动态创建form 完成form 提交

        
    document.body.appendChild(jForm) won't work because jForm is not a dom element, it is a jQuery object so add the below script before jForm.submit();
    
    jForm.appendTo('body')
    function loadPage(url, projectName) {
        var jForm = $('<form></form>', {
            action: url,
            method: 'post'
        });
    
        $("<input>", {
            name: 'curPrj',
            value: projectName
        }).appendTo(jForm);
    
        jForm.appendTo('body').submit();
    }
     var form = $("<form method='post'></form>"),
            input;
        form.attr({ "action": url });
        $.each(args, function (key, value) {
            input = $("<input type='hidden'>");
            input.attr({ "name": key });
            input.val(value);
            form.append(input);
        });
        form.appendTo('body').submit();
  • 相关阅读:
    团队冲刺03
    梦断代码 阅读笔记02
    团队冲刺02
    团队冲刺01
    周总结
    团队工作任务
    阅读笔记3
    梦断代码阅读笔记01
    周总结
    NABCD项目分析
  • 原文地址:https://www.cnblogs.com/871735097-/p/5101757.html
Copyright © 2011-2022 走看看