zoukankan      html  css  js  c++  java
  • jquery的ajaxSubmit()和多文件上传

    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

    <%

    String path = request.getContextPath();

    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

    %>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

    <html>

      <head>

        <base href="<%=basePath%>">

       

        <title>My JSP 'fileupload.jsp' starting page</title>

       

    <meta http-equiv="pragma" content="no-cache">

    <meta http-equiv="cache-control" content="no-cache">

    <meta http-equiv="expires" content="0">   

    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">

    <meta http-equiv="description" content="This is my page">

    <!--

    <link rel="stylesheet" type="text/css" href="styles.css">

    -->

      </head>

      <script type="text/javascript" src="./js/jquery.js" ></script>

    <script type="text/javascript" src="./js/jquery.form.js"></script>

      <script type="text/javascript">

    $(document).ready(function(){

         

                  

                $("#button").click(function () {

                 alert("所做的批量处理操作没有成功,请重试");

                subForm();

                }); 

        });

    //-------------------form---------------------------------

    //表單的異步提交

    var options = {

    //iframe:true,

    dataType:"xml", // 或'script',不能用'json',这种方式在三种浏览器中都不行,即回调函数不执行

      type:'post',

      url: "/SHOPcity/servlet/uploadTest", //http://localhost:8080/SHOPcity/fileupload.jsp

      beforeSubmit:showRequest,  // pre-submit callback

           success:showResponse,

           clearForm:true ,

           // other available options:

          // target:'#baseInfo_iframe'   // target element(s) to be updated with server response

           //resetForm: true        // reset the form after successful submit

           // $.ajax options can be used here too, for example:

           //timeout:   3000

         };

    function subForm(){

    alert("xxxx");

    $("#myform").ajaxSubmit(options);

    }

         function showRequest(formData, jqForm, options) {

      var queryString = $.param(formData);

             alert('About to submit: \n\n' + queryString);

      }

     

    function showResponse(responseText, statusText)   {

    var dataType;

    $(responseText).find("msg").each(function() {

       var field = $(this);

        //field.attr("nub");//读取节点属性

       dataType = field.find("content").text();//读取子节点的值

      

    });

              alert('status: ' + statusText + '\n\nresponseText: \n' + responseText+'\n:'+ dataType );

    }

      </script>

      <body>

        jaThis is my JSP page. <br>

       

         <form name="myform" id="myform" action="./servlet/uploadTest" method="post" enctype="multipart/form-data">

    File:<br>

    <input type="text" name="txtlink" ><br/>

    <input type="file" name="myfile1"><br>

    <input type="file" name="myfile2"><br>

    <input type="file" name="myfile3"><br>

    <textarea name="textarea" rows="10" cols="30">  </textarea>

    <br>

     

      <button type="button" id="button">提交</button>

    </form>

      </body>

    </html>

    http://hi.baidu.com/zjcjava/item/1080cf4a76558907c01613f0

  • 相关阅读:
    Hadoop源代码分析
    Java中如何把两个数组合并为一个
    数据库死锁的解决办法
    Java程序中解决数据库超时与死锁
    mysql 死锁检查
    JDBC事务和数据库事务嵌套的讨论 .
    嵌套事务和事务保存点的错误处理
    java string常见操作题
    java基本数据类型包装类
    java string
  • 原文地址:https://www.cnblogs.com/y0umer/p/3839186.html
Copyright © 2011-2022 走看看