zl程序教程

您现在的位置是:首页 >  前端

当前栏目

jquery$.ajax入门应用一

2023-06-13 09:14:07 时间
前台 
复制代码代码如下:

<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<title>无标题页</title>
<scripttype="text/javascript"src="jquery/jquery.js"></script>
<scripttype="text/javascript">
//这个方法把ajax方法封装一下,方便调用。
functionmyajax(){
$.ajax({
type:"get",
url:"ajax.aspx",
data:"",
dataType:"html",
success:callback
});
}
//回调函数
functioncallback(data){
$("#response").append(data);
}
//onload()事件
$(function(){
$("#confirm").click(myajax);
})
</script>
</head>
<body>
<divid="confirm">点击</div>
<divid="response">接收后台数据</div>
</body>
</html>

后台
复制代码代码如下:

usingSystem;
usingSystem.Data;
usingSystem.Configuration;
usingSystem.Collections;
usingSystem.Web;
usingSystem.Web.Security;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
usingSystem.Web.UI.WebControls.WebParts;
usingSystem.Web.UI.HtmlControls;
publicpartialclassajax:System.Web.UI.Page
{
protectedvoidPage_Load(objectsender,EventArgse)
{
Response.Write("hello");
Response.End();
}
}