jquery $.ajax入門應(yīng)用二
更新時(shí)間:2008年11月19日 16:09:22 作者:
jquery $.ajax的應(yīng)用實(shí)例
前臺
<!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>無標(biāo)題頁</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">
//這個(gè)方法把a(bǔ)jax方法封裝一下,方便調(diào)用。
function myajax(){
$.ajax({
type:'get',
url:'ajax.aspx',
data:'id=1name=tree',
dataType:'html',
beforeSend:beforecall,
success:callback
});
}
//調(diào)用前方法
function beforecall(){
$('#wait').addClass("show").append('調(diào)出中...');
//alert('');//測試是否調(diào)用
}
//回調(diào)函數(shù)
function callback(data){
$('#response').append(data);
$('#wait').css("display","none");
}
//onload()事件
$(function(){
$('#confirm').click(myajax);
})
</script>
</head>
<body>
<div id="confirm">點(diǎn)擊</div>
<div id="response">接收后臺數(shù)據(jù)</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();
}
復(fù)制代碼 代碼如下:
<!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>無標(biāo)題頁</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">
//這個(gè)方法把a(bǔ)jax方法封裝一下,方便調(diào)用。
function myajax(){
$.ajax({
type:'get',
url:'ajax.aspx',
data:'id=1name=tree',
dataType:'html',
beforeSend:beforecall,
success:callback
});
}
//調(diào)用前方法
function beforecall(){
$('#wait').addClass("show").append('調(diào)出中...');
//alert('');//測試是否調(diào)用
}
//回調(diào)函數(shù)
function callback(data){
$('#response').append(data);
$('#wait').css("display","none");
}
//onload()事件
$(function(){
$('#confirm').click(myajax);
})
</script>
</head>
<body>
<div id="confirm">點(diǎn)擊</div>
<div id="response">接收后臺數(shù)據(jù)</div>
<div id="wait" class="hide">hello</div>
</body>
</html>
后臺
復(fù)制代碼 代碼如下:
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("hello"+Request["name"]);
Response.End();
}
相關(guān)文章
全面解析jQuery中的$(window)與$(document)的用法區(qū)別
這篇文章主要介紹了jQuery中的$(window)與$(document)的用法區(qū)別,具體內(nèi)容大家可查看下文的詳細(xì)講解,感興趣的小伙伴們可以參考一下。2017-08-08jquery實(shí)現(xiàn)Li滾動(dòng)時(shí)滾動(dòng)條自動(dòng)添加樣式的方法
這篇文章主要介紹了jquery實(shí)現(xiàn)Li滾動(dòng)時(shí)滾動(dòng)條自動(dòng)添加樣式的方法,實(shí)例分析了jquery響應(yīng)鼠標(biāo)事件及動(dòng)態(tài)添加樣式的相關(guān)技巧,需要的朋友可以參考下2015-08-08jquery easyui如何實(shí)現(xiàn)格式化列
本篇文章主要介紹了jquery easyui如何實(shí)現(xiàn)格式化列 ,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-07-07基于jQuery的input輸入框下拉提示層(自動(dòng)郵箱后綴名)
基于jQuery的input輸入框下拉提示層,方便用戶輸入郵箱時(shí)的提示信息,需要的朋友可以參考下2012-06-06