JQ 文件上傳表單提交 回調

正文```javascript

<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>文件上傳</title> <script src="static/js/jquery.min.js" type="text/javascript"></script> <script type="text/javascript" src="static/js/jquery-form.js"></script> <script type="text/javascript"> function subimtBtn() { var form = $("form[name=fileForm]"); var options = { url:'${pageContext.servletContext.contextPath}/servlet/imageUploadServlet', type:'post', success:function(data) { var jsondata = eval("("+data+")"); if(jsondata.error == "0"){ var url = jsondata.url; alert(url) $("#img").attr("src",url); }else{ var message = jsondata.message; alert(message); } } }; form.ajaxSubmit(options); //$("#fileForm").submit(); } </script> </head> <body> <div class="modal-body"> html

<form action='${pageContext.servletContext.contextPath}/servlet/imageUploadServlet' enctype="multipart/form-data" method="post" id="fileForm" name="fileForm">  
                <input type="file" name="filename">  
            </form>  

        </div>  

        <div class="modal-footer">  
            <button class="btn btn-primary"  onclick="subimtBtn();">提交</button>  
        </div>  

<div>  
 ![img]()  
</div>

</body> </html> ```java

下載地址:``` jar和js.rarjquery

相關文章
相關標籤/搜索