iframe+form表单提交数据

    <h6>基于iframe+Form表单</h6>
    <iframe id="iframe" name="ifra" onclick="AjaxSubmit5()"></iframe>
    <form id="fm" action="/app04/ajax1/" method="POST" target="ifra">
        <input name="root" value="111111"/>
        <a onclick="AjaxSubmit5()">提交</a>
    </form>

 通过form的target 与iframe的name进行关联

function AjaxSubmit5() {
        //提交之前绑定
        document.getElementById('iframe').onload=reload;
        document.getElementById('fm').submit()
    }

    function reload() {//提交之后取值
        //用jQuery找
     // console.log($(ths).contents().find('body').html())
        var content = this.contentWindow.document.body.innerHTML;//this代表iframe标签
      var obj=JSON.parse(content);//转换成json对象

    }
原文地址:https://www.cnblogs.com/wangyue0925/p/9198672.html