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

回车使用ajax提交form表单
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<script type="text/javascript" src="${basePath}/js/jquery/jquery.js"></script>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>Insert title here</title>
		<script type="text/javascript">

	function sub(){
			$.ajax({
				type:"POST",
				url:url,
				data:"pageSize=6",
				success:function(msg){
					alert("success");
				}
			})
			
			return false;
	}
</script>
	</head>
	<body>

		<form action="" onkeydown="if(event.keyCode==13) return sub();">
			<input id="inputId" />
			<input type="button" value="sub" onclick="sub();" />
		</form>

	</body>
</html>