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

AJAX JQuery实现AJAX请求的第二种方式

2017-12-26 17:25 330 查看
<%@ 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() {

$("#btnAjax").click(function () {
$.ajax({
type: "POST",
url: "GetDate.ashx",
data: "name=John&location=Boston",
success: function (msg) { //回调函数,msg是服务器返回的数据
alert("Data Saved: " + msg);
}
});
});

});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input type="button" value="AJAX获取数据" id="btnAjax" />
</div>
</form>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ajax asp jquery