以下为引用内容:
<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();
}