日期:2014-05-16  浏览次数:20601 次

jquer ajax 提交表单
<script src="<%=request.getContextPath() %>/js/jquery-1.7.2.min.js" type="text/javascript"></script>
  <script src ="<%=request.getContextPath() %>/js/jquery.form.js" type ="text/javascript" ></script>
   <script type="text/javascript">
         $(document).ready(function()
            {
                $('#form1').submit(function()//提交表单
                {
                    //alert("ddd");
                    var options = {
                    url:'<%=request.getContextPath() %>/stu.do?method=jqueryajax', //提交给哪个执行
                    type:'POST',
                    success: function(data){
alert(data);
} //显示操作提示
                    };
                    $('#form1').ajaxSubmit(options);
                    return false; //为了不刷新页面,返回false,反正都已经在后台执行完了,没事!

                }); 
            }
         );
     </script>

struts1后台:tishi = "123";
PrintWriter pw=response.getWriter();
pw.print(tishi);
pw.close();

return null;

struts2后台:tishi = "1";
response.getWriter().write(tishi);

return mapping.findForward("addPage");