jquery $.ajax入門應用二
更新時間:2008年11月19日 16:09:22 作者:
jquery $.ajax的應用實例
前臺
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>無標題頁</title>
<style type="text/css">
.show{ display:block;}
.hide{ display:none;}
</style>
<script type="text/javascript" src="jquery/jquery-1.2.6.js"></script>
<script type="text/javascript">
//這個方法把ajax方法封裝一下,方便調用。
function myajax(){
$.ajax({
type:'get',
url:'ajax.aspx',
data:'id=1name=tree',
dataType:'html',
beforeSend:beforecall,
success:callback
});
}
//調用前方法
function beforecall(){
$('#wait').addClass("show").append('調出中...');
//alert('');//測試是否調用
}
//回調函數
function callback(data){
$('#response').append(data);
$('#wait').css("display","none");
}
//onload()事件
$(function(){
$('#confirm').click(myajax);
})
</script>
</head>
<body>
<div id="confirm">點擊</div>
<div id="response">接收后臺數據</div>
<div id="wait" class="hide">hello</div>
</body>
</html>
后臺
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("hello"+Request["name"]);
Response.End();
}
復制代碼 代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>無標題頁</title>
<style type="text/css">
.show{ display:block;}
.hide{ display:none;}
</style>
<script type="text/javascript" src="jquery/jquery-1.2.6.js"></script>
<script type="text/javascript">
//這個方法把ajax方法封裝一下,方便調用。
function myajax(){
$.ajax({
type:'get',
url:'ajax.aspx',
data:'id=1name=tree',
dataType:'html',
beforeSend:beforecall,
success:callback
});
}
//調用前方法
function beforecall(){
$('#wait').addClass("show").append('調出中...');
//alert('');//測試是否調用
}
//回調函數
function callback(data){
$('#response').append(data);
$('#wait').css("display","none");
}
//onload()事件
$(function(){
$('#confirm').click(myajax);
})
</script>
</head>
<body>
<div id="confirm">點擊</div>
<div id="response">接收后臺數據</div>
<div id="wait" class="hide">hello</div>
</body>
</html>
后臺
復制代碼 代碼如下:
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("hello"+Request["name"]);
Response.End();
}
相關文章
jQuery ajax提交Form表單實例(附demo源碼)
這篇文章主要介紹了jQuery ajax提交Form表單的方法,結合實例分析了jQuery ajax操作實現表單提交的相關技巧,并附帶demo源碼供讀者下載參考,需要的朋友可以參考下2016-04-04
BootStrap glyphicon圖標無法顯示的解決方法
如果不注意bootstrap引入css和fonts的規(guī)范,則可能會導致bootstrap 在顯示glyphicon圖標時無法正常顯示,顯示為方框。該怎么解決呢?下面小編給大家解答下2016-09-09

