<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="JqueryAjax.aspx.cs" Inherits="XXX.WebApp.JqueryAjax" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<script src="../Js/jquery-1.7.1.js"></script>
<script type="text/javascript">
$(function() {
//get请求
$("#btnGet").click(function(){
$.get("GetDate.ashx", { "name": "lisi", "pwd": "123" }, function (data) { //get请求,function是回调函数,data是从服务器返回的数据
alert(data)
});
});
//post请求
$("#btnPost").click(function () {
$.post("ShowDate.aspx", { "name": "lisi", "pwd": "123" }, function (data) { //post请求
alert(data)
})
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input type="button" value="GET获取数据" id="btnGet" />
<input type="button" value="POST获取数据" id="btnPost" />
</div>
</form>
</body>
</html>