jQuery 异步提交表单实例解析

以下为引用内容:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery 异步提交表单实例解析</title>
</head>
<script src="js/jquery-1.4.2.js"></script>
<script>

 
$('#f1').submit(function() {
$.ajax({
url: 'updateOrAddUser.action',
data: $('#f1').serialize(),
type: "post",
cache : false,
beforeSend:function(){
 if(!validateAll()){
  return false;
 }
},
success: function()
{

 
 jQuery("#content").load("searchUsers.action?"+(new Date()).valueOf());
}
});
return false;
});


</script>
<body>
<form id="f1" name="f1">
<input name="a1" />
<input name="a2" />
<input id="File1" type="file" name="File1"/>
<input id="Submit1" type="submit" value="submit" />
</form>
</body>
</html>

-------------------------------------

后台:
 PrintWriter out = null;
  response.setContentType("text/html;charset=UTF-8");
  try {
   out = response.getWriter();
   out.write(jsonStr);
  } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }finally{
   out.close();
  }

posted on 2013-02-20 21:14  世界之大追梦者  阅读(183)  评论(0编辑  收藏  举报

导航