延迟提交表单

问题描述,表单未提交而窗口关闭。(自动提交同时可能造成EOFException,减少对请求流的处理(如文件大小检查),让请求尽快完成)

script>

 function  testSubmit(){
   var  form=document.getElementById("form1");
  form.submit();
  window.close(); 
  }
 </script>
 <body scroll="no">
   <form id="form1" action="fileUploadController.do?uploadfile2" enctype="multipart/form-data" method="post">  
        file:<input type="file" name="file"><br>  
        <input type="button" value="提交"  onclick="testSubmit()">  
    </form>  

 </body>

1.可以将action 设置为action="#",在testSubmit中重新对action 赋值

  var  form=document.getElementById("form1");

  form.attr("action","fileUploadController.do?uploadfile2" );

 form.submit();

 window.close();

2.js函数源代码的跟踪eventListeners对源代码进行快速定位

    【1】选中要追踪的element,---->检查

 在  EventListeners里有源文件的链接------>

【2】点击源文件所在的位置,跳转到js源文件



猜你喜欢

转载自blog.csdn.net/qq_25717027/article/details/72857982