您的位置:首页 > Web前端 > JQuery

AJAX 利用JQuery实现AJAX请求

2017-12-26 17:22 411 查看
<%@ 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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ajax asp jquery