加入收藏 | 设为首页 | 会员中心 | 我要投稿 辽源站长网 (https://www.0437zz.com/)- 云专线、云连接、智能数据、边缘计算、数据安全!
当前位置: 首页 > 站长资讯 > 传媒 > 正文

使用jQuery简化ajax操作的实例代码

发布时间:2018-08-23 20:18:15 所属栏目:传媒 来源:站长网
导读:使用 jQuery 简化ajax操作的实例代码 Copy to Clipboard 引用的内容:[www.veryhuo.com]%@ Page Language=C# ContentType=text/html ResponseEncoding=gb2312% script runat=server protected void Page_Load(object sender, EventArgs e) { if (!IsPostBa

使用jQuery简化ajax操作的实例代码

Copy to ClipboardLiehuo.Net Codes引用的内容:[www.veryhuo.com] <%@ Page Language="C#" ContentType="text/html" ResponseEncoding="gb2312"%>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Request.Form["name"] != null)
{
System.Threading.Thread.Sleep(3000);
Response.Write(Request.Form["name"] + ":你好,异步通信数据传输成功!");
Response.End();
}
}
}
</script>
<html>
<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
body{font-size:12px; line-height:30px;}
</style>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
//提交数据
function ajax(){
$.post(
"index.aspx",
{
name:"尊敬的朋友"
},
function(data){
$("#divData").text(data);
}
)
}

$(document).ready(function(){
//开始请求
$("#jindu").ajaxStart(function(){
$("#divData").html(null);
$(this).show();
});
//请求结束时
$("#jindu").ajaxStop(function(){
$(this).hide();
});
});
</script>
</head>
<body>
<input id="Button1" type="button" value="异步通信测试" onclick="ajax();" />
<div id="divData"></div>
<div id="jindu" style="display:none;">数据正在提交,请稍后…</div>
</body>
</html>

(编辑:辽源站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读