30.jquery的ajax方法

JQuery中的ajax()方法
  * 注意:使用的时候$.ajax();方式来调用
  * 该方法的参数

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!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" src="${ pageContext.request.contextPath }/js/jquery-1.8.3.js"></script>
<script type="text/javascript">
	$(function(){
		$("input[type='button']").click(function(){
			//使用post方法
			var url="${pageContext.request.contextPath}/ajax1";
			var jsonData={"pname":"赵六"};
			
			$.ajax({
				"url":url,
				"data":jsonData,
				"dataType":"json",
				"success":function(data){
					alert(data.name); 
				}
			});
		});
	});
</script>
</head>
<body>

<h3>jQuery中的ajax的入门(使用$.ajax方法)</h3>

<input type="button" value="点击" />

<h4 id="h4Id"></h4>
</body>
</html>

  

posted @ 2018-02-24 12:37  一日看尽长安花cxjj  阅读(124)  评论(0)    收藏  举报