使用jquery實(shí)現(xiàn)簡(jiǎn)單的ajax
更新時(shí)間:2013年07月08日 09:20:32 作者:
本篇文章是對(duì)用jquery實(shí)現(xiàn)簡(jiǎn)單的ajax的實(shí)現(xiàn)方法進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
-->html頁(yè)
<!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>用戶名校驗(yàn)實(shí)例</title>
<script src="../js/jquery-1.7.2.js" type="text/javascript"></script>
<script src="../js/verify.js" type="text/javascript"></script>
</head>
<body onload="verify()">
用戶名校驗(yàn)的jax實(shí)例
<!--ajax方式下不需要使用表單進(jìn)行數(shù)據(jù)提交,因此不用寫表單-->
<input type="text" value="" id="userName" />
<input type="button" value="提交" onclick=""/>
<!--預(yù)留空間,顯示結(jié)果-->
<div id="result"></div>
<!--div is block,but span is inline--->
</body>
</html>
—>js頁(yè)
function verify() {
$("#userName").keyup(function () {
var user = $(this).val();
var userobj = $(this);
$.post("../index.aspx", { userobj: user }, callback);
});
}
function callback(data) {
$("#result").text(data);
}
—>aspx頁(yè)
<%
Response.Clear();
string str_name = Request["userobj"];
if (str_name == "xtyang")
{
Response.Write("ok");
}
else
{
Response.Write("no");
}
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>用戶名校驗(yàn)實(shí)例</title>
<script src="../js/jquery-1.7.2.js" type="text/javascript"></script>
<script src="../js/verify.js" type="text/javascript"></script>
</head>
<body onload="verify()">
用戶名校驗(yàn)的jax實(shí)例
<!--ajax方式下不需要使用表單進(jìn)行數(shù)據(jù)提交,因此不用寫表單-->
<input type="text" value="" id="userName" />
<input type="button" value="提交" onclick=""/>
<!--預(yù)留空間,顯示結(jié)果-->
<div id="result"></div>
<!--div is block,but span is inline--->
</body>
</html>
—>js頁(yè)
復(fù)制代碼 代碼如下:
function verify() {
$("#userName").keyup(function () {
var user = $(this).val();
var userobj = $(this);
$.post("../index.aspx", { userobj: user }, callback);
});
}
function callback(data) {
$("#result").text(data);
}
—>aspx頁(yè)
復(fù)制代碼 代碼如下:
<%
Response.Clear();
string str_name = Request["userobj"];
if (str_name == "xtyang")
{
Response.Write("ok");
}
else
{
Response.Write("no");
}
Response.End();
%>
相關(guān)文章
jQuery動(dòng)態(tài)生成表格及右鍵菜單功能示例
這篇文章主要介紹了jQuery動(dòng)態(tài)生成表格及右鍵菜單功能,結(jié)合實(shí)例形式分析了jQuery表格的動(dòng)態(tài)操作及鼠標(biāo)事件響應(yīng)相關(guān)技巧,需要的朋友可以參考下2017-01-01
基于jquery的滾動(dòng)鼠標(biāo)放大縮小圖片效果
基于jquery的滾動(dòng)鼠標(biāo)放大縮小圖片效果,需要的朋友可以參考下。2011-10-10
jquery處理頁(yè)面彈出層查詢數(shù)據(jù)等待操作實(shí)例
這篇文章主要介紹了jquery處理頁(yè)面彈出層查詢數(shù)據(jù)等待操作,實(shí)例分析了jquery實(shí)現(xiàn)等待效果的技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-03-03
JavaScript和JQuery實(shí)用代碼片段(一)
JavaScript和JQuery實(shí)用代碼片段,喜歡學(xué)習(xí)jquery的朋友可以參考下。2010-04-04
jQuery實(shí)現(xiàn)的簡(jiǎn)單無(wú)刷新評(píng)論功能示例
這篇文章主要介紹了jQuery實(shí)現(xiàn)的簡(jiǎn)單無(wú)刷新評(píng)論功能,涉及jQuery事件響應(yīng)及頁(yè)面元素屬性動(dòng)態(tài)操作相關(guān)實(shí)現(xiàn)技巧,代碼中備有較為詳盡的注釋便于理解,需要的朋友可以參考下2017-11-11
一個(gè)CSS+jQuery實(shí)現(xiàn)的放大縮小動(dòng)畫效果
放大縮小動(dòng)畫效果實(shí)現(xiàn)的方法有很多,下面有個(gè)不錯(cuò)的示例,使用CSS+jQuery實(shí)現(xiàn)的,感興趣的朋友可以了解下2014-02-02
firefox下jquery ajax返回object XMLDocument處理方法
使用jquery ajax處理struts2 返回json類型的時(shí)候,ajax執(zhí)行成功返回結(jié)果為object XMLDocument,解決方法如下2014-01-01

