使用jquery實(shí)現(xiàn)簡單的ajax
更新時(shí)間:2013年07月08日 09:20:32 作者:
本篇文章是對(duì)用jquery實(shí)現(xiàn)簡單的ajax的實(shí)現(xiàn)方法進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
-->html頁
<!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頁
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頁
<%
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頁
復(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頁
復(fù)制代碼 代碼如下:
<%
Response.Clear();
string str_name = Request["userobj"];
if (str_name == "xtyang")
{
Response.Write("ok");
}
else
{
Response.Write("no");
}
Response.End();
%>
相關(guān)文章
jQuery autocomplate 自擴(kuò)展插件、自動(dòng)完成示例代碼
jquery-lib版本是 1.3.2的,該插件是簡單的擴(kuò)展插件,代碼也比較簡單的封裝。所以看起來也比較簡單不是很費(fèi)力,當(dāng)然封裝得也不是很好。2011-03-03jQuery實(shí)現(xiàn)右鍵菜單、遮罩等效果代碼
這篇文章主要介紹了jQuery實(shí)現(xiàn)右鍵菜單、遮罩、彈出層效果,適應(yīng)管理系統(tǒng)界面,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-09-09JQuery操作與遍歷元素并設(shè)置其屬性、樣式和內(nèi)容
本文詳細(xì)講解了JQuery操作與遍歷元素并設(shè)置其屬性、樣式和內(nèi)容的方法,文中通過示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-04-04jquery插件treegrid樹狀表格的使用方法詳解(.Net平臺(tái))
本文主要介紹了jquery插件treegrid樹狀表格的使用方法,具有一定的參考作用,下面跟著小編一起來看下吧2017-01-01