当前位置: 代码迷 >> Ajax >> 回车施用ajax提交form表单
  详细解决方案

回车施用ajax提交form表单

热度:662   发布时间:2012-11-04 10:42:41.0
回车使用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>
  相关解决方案