第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

java中ajax怎樣實(shí)現(xiàn)查詢

java中ajax怎樣實(shí)現(xiàn)查詢

陪伴而非守候 2019-05-31 02:02:11
java中ajax怎樣實(shí)現(xiàn)查詢
查看完整描述

2 回答

?
qq_遁去的一_1

TA貢獻(xiàn)1725條經(jīng)驗(yàn) 獲得超8個(gè)贊

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html>
<head>
<script type="text/javascript">
/* 標(biāo)準(zhǔn)AJAX模板 */
//使用 false 作為判定條件,它表示還沒有創(chuàng)建 XMLHttpRequest 對(duì)象
var http_request=false;
//創(chuàng)建XMLHttpRequest對(duì)象方法
function send_request(){
http_request=false;
//火狐
if(window.XMLHttpRequest){
http_request=new XMLHttpRequest();
if(http_request.overrideMimeType){
http_request.overrideMimeType('text/xml');
}
}else if(window.ActiveXObject){//IE
try{
http_request=new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){
try{
http_request=new ActiveXObject("Microsoft.XMLHTTP");
}catch(e2){}
}
}

if(!http_request){//檢查 request 是否仍然為 false(如果一切順利就不會(huì)是 false)
window.alert("Err Create XMLHttpRequest!");
}

}

//與服務(wù)器交互
function sendReg(url)
{
//創(chuàng)建AJAX引擎
send_request();
//設(shè)定回調(diào)函數(shù)
//服務(wù)器響應(yīng)完畢以后會(huì)自動(dòng)調(diào)用回調(diào)函數(shù)一次
http_request.onreadystatechange = requestReg;
//與服務(wù)器連接
//1.提交方式(get/post)
//2.提交路徑(url)
//3.是否異步
http_request.open("get",url,true);
//使用get方法不緩存
http_request.setRequestHeader("If-Modified-Since","0");
//提交請(qǐng)求
//get null
http_request.send(null);
}

//事件函數(shù)
function test()
{
//獲得文本框的數(shù)據(jù)
var text = document.getElementById("text").value;
//get
//定義當(dāng)前訪問服務(wù)器URL
var url = "reg?text=" + text;
//使用UTF-8的編碼將字符串進(jìn)行解碼
url = encodeURI(url);
//與服務(wù)器交互
sendReg(url);
}
//定義回調(diào)函數(shù)
function requestReg()
{
//判斷就緒狀態(tài)
if(http_request.readyState == 4)
{
//判斷響應(yīng)狀態(tài)
if(http_request.status == 200)
{
//獲得服務(wù)器響應(yīng)的數(shù)據(jù)
var res = http_request.responseText;
//注意這里是通過在servlet中用out.println("****");所傳輸?shù)臄?shù)據(jù),你也可以用XML的格式來發(fā)送,那就為var res = http_request.responseXML;然后可以使用res.getElementsByTagName等DOM的解析方法來解析;這個(gè)可以到網(wǎng)上查到相關(guān)資料

//alert(res);
if(res == "true")
{
document.getElementById("result").innerHTML = "<font color='red'>此用戶名已經(jīng)被注冊(cè)了</font>";
document.getElementById("submit").disabled = true;
}
else
{
document.getElementById("result").innerHTML = "<font color='blue'>此用戶名沒有被注冊(cè)</font>";
document.getElementById("submit").disabled = false;
}
}
}
}

</script>
</head>

<body style="test-align:center" onload="add()">
<table align="center" cellspacing="0" width="500" border="0">
<tr>
<td width="100">用 戶 名</td>
<td width="200"><input type="text" id="text" onblur="test()"/></td>
<td width="200" id="result"></td>
</tr>
<tr align="center">
<td colspan="2"><input type="button" value="注冊(cè)" id="submit" disabled="disabled"/></td>
<td></td>
</tr>
</table>
</body>
</html>





查看完整回答
反對(duì) 回復(fù) 2019-06-01
  • 2 回答
  • 0 關(guān)注
  • 473 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)