ajax请求添加客户端事件的激发顺序和JSON 相关介绍
ajax请求添加客户端事件的激发顺序
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<%=DateTime.Now.ToString() %>
<hr/>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<%=DateTime.Now.ToString() %>
<hr/>
<asp:Button ID="Button1" runat="server" Text="Button" />
</ContentTemplate>
</asp:UpdatePanel>
<script type="text/javascript" language="javascript">
Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(
function(sender, e)
{
alert("add_initializeRequest");
}
);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(
function(sender,e)
{
alert("add_endRequest");
}
);
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(
function(sender,e)
{
alert("add_beginRequest");
}
);
Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(
function(sender,e)
{
alert("add_pageLoaded");
}
);
Sys.WebForms.PageRequestManager.getInstance().add_pageLoading(
function(sender,e)
{
alert("add_pageLoading");
}
);
</script>
</form>
JSON
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
<script type="text/javascript">
function show()
{
var UserList = [
{UserID:01, "Name":{"FirstName":"Truly","LastName":"Zhu"}, Email:"zhuleipro@hotmail.com"},
{UserID:02, "Name":{"FirstName":"Jeffrey","LastName":"Richter"}, Email:"xxx@xxx.com"},
{UserID:03, "Name":{"FirstName":"Scott","LastName":"Gu"}, Email:"xxx2@xxx2.com"}
];
alert(UserList[1]["Name"].FirstName);
alert(UserList[2].Email);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input id="Button1" type="button" value="button" onclick="show()" /></div>
</form>
</body>
</html>
运行结果:当你点击按钮的时候 弹出:Truly 在弹出:xxx@xxx.com