jquery代码:
<script type="text/javascript" src="../js/jquery-1.8.3.min.js"></script> <script type="text/javascript" src="../js/jquery-form.js"></script> <script type="text/javascript"> // 用于form表单提交后不跳转 function addBook() { $("#addBookForm").ajaxSubmit(function(message) { $("#tips").text(message); // console.log(decodeURI("传回数据:"+message)); }); return false; } </script>
html代码:
<form id="addBookForm" action="../com/yh/myServlet/AddBookServlet" enctype="multipart/form-data" method="post" onsubmit="return addBook()"> 图书名:<input type="text" name="bookName"> <br /> 出版社:<input type="text" name="press"><br /> <input type="submit" value="提交"> </form>