zoukankan      html  css  js  c++  java
  • form+iframe+file 页面无刷新上传文件并获取返回值

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Title</title>
    </head>
    <body>
    <button id="aa">上传</button>
    <form id="ajaxUploadform" action="/api/upload" role="form" method="post" target="ajaxIframe" enctype="multipart/form-data">
    <input type="file" id="ajaxFile" name="ajaxFile"/></form>
    <iframe name='ajaxIframe' id='ajaxIframe' ></iframe>
    <script>
    var aa=document.getElementById("aa");
    aa.addEventListener("click",function(){
    document.getElementById("ajaxUploadform").submit()
    document.getElementById("ajaxIframe").onload=function(){
    var result=document.getElementById('ajaxIframe').contentWindow.document.body.innerText;
    alert(result)
    }
    },false)

    </script>

    </body>
    </html>
  • 相关阅读:
    time fly
    小论文初稿终于完成
    leetcode之Length of Last Word
    static关键字
    参数传递
    this关键字
    面向对象有三大特征
    空指针异常
    变量按数据类型分为
    构造方法
  • 原文地址:https://www.cnblogs.com/liuhao-web/p/9987199.html
Copyright © 2011-2022 走看看