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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

誰有能運(yùn)行的search.jsp的代碼啊,發(fā)一下。我的不能運(yùn)行,只能得到那個(gè)xmlHttp對(duì)象,感激不盡,

我在那個(gè)callback那個(gè)函數(shù)那里就沒反應(yīng)了

正在回答

4 回答

td.onclick?=?function(){????????????????????//這個(gè)方法實(shí)現(xiàn)的是,當(dāng)用鼠標(biāo)點(diǎn)擊一個(gè)關(guān)聯(lián)數(shù)據(jù)時(shí),關(guān)聯(lián)數(shù)據(jù)自動(dòng)填充到輸入框中。?????????????????????????????????????};

這個(gè)里面的代碼怎么寫


0 回復(fù) 有任何疑惑可以回復(fù)我~
<%@?page?language="java"?import="java.util.*"?pageEncoding="UTF-8"%>
<html>
??<head>
????<style?type="text/css">
????	#mydiv{
????	position:?absolute;
????	left:50%;
????	top:50%;
????	margin-left:?-200px;
????	margin-top:?-120px;
????	}
????	.mouseOver{
????		background:?#708090;
????		color:#FFFAFA;
????	}
????	.mouseOut{
????		background:?#FFFAFA;
????		color:#000;
????	}
????</style>
????<script?type="text/javascript">
????	var?xmlHttp;
????	//1.獲得用戶輸入內(nèi)容的關(guān)聯(lián)信息的函數(shù)
????	function?getMoreContents(){
	????	//首先獲得用戶輸入
	????	var?content?=?document.getElementById("keyword");
	????	if(content.value?==?""){
	????		//當(dāng)輸入框?yàn)榭諘r(shí),清空之前的數(shù)據(jù)
	????		clearContent();
	????		return;
	????	}
	????	//alert(content.value);
	????	//2.然后要給服務(wù)器發(fā)送用戶輸入的內(nèi)容,因?yàn)槲覀儾捎玫氖莂jax異步發(fā)送數(shù)據(jù),所以我們要使用xmlHttp對(duì)象
	????	//xmlHttp?=?獲得xmlHttp對(duì)象;
			xmlHttp?=?createXMLHttp();??
			//alert(xmlHttp);??	
	????	//3.要給服務(wù)器發(fā)送數(shù)據(jù),首先定義一個(gè)服務(wù)器的地址,
	????	var?url?=?"search?keyword="+escape(content.value);
	????	//true表示JavaScript腳本會(huì)在send()方法之后繼續(xù)執(zhí)行,而不會(huì)等待來自服務(wù)器的響應(yīng)。
	????	xmlHttp.open("GET",url,true);
	????	//xmlHttp綁定回調(diào)方法,這個(gè)回調(diào)方法會(huì)在xmlHttp狀態(tài)改變的時(shí)候會(huì)被調(diào)用
	????	//xmlHttp的狀態(tài):0-4,我們只關(guān)心4(complete)這個(gè)狀態(tài),所以說當(dāng)完成之后,再調(diào)用回調(diào)函數(shù)才有意義。
	????	xmlHttp.onreadystatechange?=?callback;
	????	//參數(shù)已經(jīng)在url中了,不用在此處添加參數(shù)
	????	xmlHttp.send(null);
????	}
????	
????	
????	
????	//獲得xmlHttp對(duì)象
????	function?createXMLHttp(){
????		//對(duì)于大多數(shù)瀏覽器都適用的
????		var?xmlHttp;
????		if(window.XMLHttpRequest){
????			xmlHttp?=?new?XMLHttpRequest();
????		}
????		//要考慮瀏覽器的兼容性
????		if(window.ActiveXObject){
????			xmlHttp?=?new?ActiveXObject("Microsoft.XMLHTTP");
????			//如果瀏覽器有ActiveXObject對(duì)象,但沒有Microsoft.XMLHTTP的參數(shù)
????			if(!xmlHttp){
????				xmlHttp?=?new?ActiveXObject("Msxml2.XMLHTTP");
????			}
????		}
????		return?xmlHttp;
????	}
????	//回調(diào)函數(shù)
????	function?callback(){
????		//4表示完成
????		if(xmlHttp.readyState?==?4){
????			//200代表服務(wù)器響應(yīng)成功,404代表資源未找到,500代表服務(wù)器內(nèi)部錯(cuò)誤
????			if(xmlHttp.status?==?200){
????				//交互成功,獲得相應(yīng)的數(shù)據(jù),是文本格式。
????				var?result?=?xmlHttp.responseText;
????				//解析獲得的數(shù)據(jù)
????				var?json?=?eval("("+result+")");
????				//獲得這些數(shù)據(jù)之后,就可以動(dòng)態(tài)的顯示數(shù)據(jù)了。把這些數(shù)據(jù)展示到輸入框下面。
????				//alert(json);
????				setContent(json);
????			}
????		}
????	}
????	//設(shè)置關(guān)聯(lián)數(shù)據(jù)的展示,參數(shù)代表服務(wù)器傳遞過來的關(guān)聯(lián)數(shù)據(jù)
????	function?setContent(contents){
????		//清空之前的數(shù)據(jù)
????		clearContent();
????		//設(shè)置位置
????		setLocaltion();
????		//首先獲得關(guān)聯(lián)數(shù)據(jù)的長(zhǎng)度,以此來確定生成多少個(gè)<tr></tr>
????		var?size?=?contents.length;
????		//設(shè)置內(nèi)容
????		for(var?i?=0;i?<?size;i++){
????			var?nextNode?=?contents[i];//代表json數(shù)據(jù)的第i個(gè)元素
????			var?tr?=?document.createElement("tr");
????			var?td?=?document.createElement("td");
????			td.setAttribute("borde","0");
????			td.setAttribute("gbcolor","#FFFAFA");
????			//為td綁定兩個(gè)樣式(鼠標(biāo)進(jìn)入和鼠標(biāo)移出時(shí)事件)
????			td.onmouseover?=?function(){
????				this.className?=?'mouseOver';
????			};
????			td.onmouseout?=?function(){
????				this.className?=?'mouseOut';
????			};
????			td.onclick?=?function(){
????				//這個(gè)方法實(shí)現(xiàn)的是,當(dāng)用鼠標(biāo)點(diǎn)擊一個(gè)關(guān)聯(lián)數(shù)據(jù)時(shí),關(guān)聯(lián)數(shù)據(jù)自動(dòng)填充到輸入框中。
????				
????			};
????			td.onmousedown?=?function(){
	????????????	//當(dāng)鼠標(biāo)點(diǎn)擊一個(gè)關(guān)聯(lián)數(shù)據(jù)時(shí),自動(dòng)在輸入框添加數(shù)據(jù)
	????????????	document.getElementById("keyword").value?=this.innerText;
	
	???????????};
	???????????//鼠標(biāo)懸浮于關(guān)聯(lián)數(shù)據(jù)上時(shí),自動(dòng)添加到輸入框中
????			?/*?td.onmouseover?=?function(){
		?????????????this.className?=?'mouseOver';
		?????????????if(td.innerText?!=?null)
		?????????????document.getElementById("keyword").value?=this.innerText;
				
				}?*/
????			
????			
????			//創(chuàng)建一個(gè)文本節(jié)點(diǎn)
????			var?text?=?document.createTextNode(nextNode);
????			td.appendChild(text);
????			tr.appendChild(td);
????			document.getElementById("content_table_body").appendChild(tr);
????		}
????	}
????		//清空之前的數(shù)據(jù)
????		function?clearContent(){
????			var?contentTableBody?=?document.getElementById("content_table_body");
????			var?size?=?contentTableBody.childNodes.length;
????			//刪除時(shí),從下往上刪
????			for(var?i?=?size-1;i>=0;i--){
????				//指定刪除第i個(gè)子節(jié)點(diǎn)
????				contentTableBody.removeChild(contentTableBody.childNodes[i]);
????			}
????			//清除關(guān)聯(lián)數(shù)據(jù)的外邊框
????			var?popDiv?=?document.getElementById("popDiv").style.border="none";
????		
????		}
????		//當(dāng)輸入框失去焦點(diǎn)時(shí),清空之前的數(shù)據(jù)
????		function?keywordBlur(){
????			clearContent();
????		}
????		//設(shè)置顯示關(guān)聯(lián)信息的位置
????		function?setLocaltion(){
????			//關(guān)聯(lián)信息的顯示位置要和輸入框一致
????			var?content?=?document.getElementById("keyword");
????			var?width?=?content.offsetWidth;//輸入框的長(zhǎng)度
????			var?left?=?content["offsetLeft"];//到左邊框的距離
????			var?top?=?content["offsetTop"]+content.offsetHeight;//到頂部的距離(加上輸入框本身的高度)
????			//獲得顯示數(shù)據(jù)的div
????			var?popDiv?=?document.getElementById("popDiv");
????			popDiv.style.border?=?"gray?1px?solid";
????			popDiv.style.left?=?left+"px";
????			popDiv.style.top?=?top+"px";
????			popDiv.style.width?=?width+"px";
????			document.getElementById("content-table").style.width?=?width+"px";
????		}
????</script>
??</head>
??
??<body>
???<div?id="mydiv">
???	<!--?輸入框?-->
???	<input?type="text"?size="50"?id="keyword"?onkeyup="getMoreContents()"?onblur="keywordBlur()"?onfocus="getMoreContents()"/>
???	<input?type="button"?value="百度一下"?width="50px"/>
???	<!--?下面是內(nèi)容展示區(qū)域?-->
???	<div?id="popDiv">
???		<table?id="content-table"?bgcolor="#FFFAFA"?border="0"?cellspacing="0"?cellpadding="0">
???			<tbody?id="content_table_body">
???				<!--?動(dòng)態(tài)查詢出來的數(shù)據(jù)顯示在這里?-->
???				
???			</tbody>
???		</table>
???	</div>
???</div>
??</body>
</html>


1 回復(fù) 有任何疑惑可以回復(fù)我~

<%@ page language="java" contentType="text/html; charset=utf-8"

? ? pageEncoding="utf-8"%>


<html>

<head>

<title>Insert title here</title>

<style type="text/css">

? ? ?#mydiv{

? ? ? ? position:absolute;

? ? ? ? left:50%;

? ? ? ? top:50%;

? ? ? ? margin-left:-200px;

? ? ? ? margin-top:-50px;

? ? ?}

? ? ?

? ? ?.mouseOver{

? ? ?background:#708090;

? ? ?color:#FFAFA;

? ? ?}

? ? ?.mouseOut{

? ? ? ?background:#FFAFA;

? ? ? ?color:#000000;

? ? ?}

</style>


<script type="text/javascript">

? ? ? ? var xmlHttp;

? ? ? ?function getMoreContents(){

? ? ? var content=document.getElementById("keyword");

? ? ? if(content.value==""){

? ? ? clearContent();

? ? ? return;

? ? ? }

? ? ? xmlHttp=getXmlHttpObject();

? ? // ? alert(xmlHttp);

? ? ? var url="search?keyword="+escape(content.value);

? ? //true ?表示js腳本會(huì)在send()方法之后繼續(xù)執(zhí)行,而不會(huì)等待來自服務(wù)器的響應(yīng)

? ? ? xmlHttp.open("GET",url,true)

? ? ? //xmlHttp綁定回調(diào)方法,這個(gè)回調(diào)方法會(huì)在xmlHttp狀態(tài)改變的時(shí)候被調(diào)用

? ? ? //xmlHttp的狀態(tài)0-4 ,我們只關(guān)心4(complete)這個(gè)狀態(tài),所以說完整之后再調(diào)用回調(diào)方法才有意義

? ? ? ? ? ? ?xmlHttp.onreadystatechange=callback;

? ? ? ? xmmlHttp.send(null);

? ? ? ? alert(xmlHttp);

? ? ? ?}

? ? ? ?function getXmlHttpObject(){

? ? ? var xmlHttp;

? ? ? if(window.XMLHttpRequest){

? ? ? xmlHttp=new XMLHttpRequest(); ??

? ? ? }

? ? ? if(window.ActiveXObject){

? ? ?xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");

? ? ?if(!xmlHttp){

? ? ?xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");

? ? ?}

? ? ? }

? ? ? return xmlHttp; ??

? ? ? ?}

? ? ? ?

? ? ? ?function callback(){

? ? ? if(xmlHttp.readyState==4){

? ? ? if(xmlHttp.status==200){

? ? ? //交互成功,獲得相應(yīng)的數(shù)據(jù),是文本格式(json)

? ? ? var result=xmlHttp.responseText;

? ? ? //解析獲得json數(shù)據(jù)

? ? ? var json =eval("("+result+")");

? ? ? //獲得數(shù)據(jù)之后,就可以動(dòng)態(tài)顯示這些數(shù)據(jù)了,展示到輸入框下面

? ? ? alert(json);

? ? ? setContent(json);

? ? ? }

? ? ??

? ? ? }

? ? ? ?}

? ? ? ?

? ? ? ? function setContent(contents){

? ? ? ? ? ? ? ?clearContent();

? ? ? ? ? ? ? ?setLocaton();

? ? ? ? ? ? ? var size=contans.length;

? ? ? ? ? ? ? for(var i=0;i<size;i++){

? ? ? ? ? ? ? var nextNode=contans[i];

? ? ? ? ? ? ? var tr=document.createElement("tr");

? ? ? ? ? ? ? var td=document.createElement("td");

? ? ? ? ? ? ? td.setAttribute("border","0");

? ? ? ? ? ? ? td.setAtrribute("bgcolor","#FFFAA");

? ? ? ? ? ? ? td.omnmouseover=function(){

? ? ? ? ? ? ? this.calssName="mouseOver";

? ? ? ? ? ? ? };

? ? ? ? ? ? ? td.onmouseout=function(){

? ? ? ? ? ? ? this.calssName="mouseOut";

? ? ? ? ? ? ? };

? ? ? ? ? ? ? td.onclick=function(){

? ? ? ? ? ? ? //這個(gè)方法實(shí)現(xiàn)的是,當(dāng)鼠標(biāo)點(diǎn)擊關(guān)聯(lián)數(shù)據(jù)時(shí),自動(dòng)設(shè)置為輸入框的數(shù)據(jù)

? ? ? ? ? ? ? };

? ? ? ? ? ? ? var text=document.createTextNode(nextNode);

? ? ? ? ? ? ? td.appendChild(text);

? ? ? ? ? ? ? tr.appendChild(td);

? ? ? ? ? ? ? document.getElementById("content_table_body").appendChild(tr);

? ? ? ? ? ? ? } ? ? ?

? ? ? ? }

? ? ? ??

? ? ? ? function clearContent(){

? ? ? ? var contentTableBody=document.getElementById("content_table_body");

? ? ? ? var size=contentTableBody.childNodes.length;

? ? ? ? for(var i=size-1;i>=0;i--){

? ? ? ? contentTableBody.removeChild(contentTableBody.childNodes[i]);

? ? ? ? }

? ? ? ? document.getElementById("popDiv").style.border="none";

? ? ? ? }

? ? ? ? //當(dāng)輸入框失去焦點(diǎn)(不去點(diǎn)他)的時(shí)候,關(guān)聯(lián)信息清空

? ? ? ? function keywordBlur(){

? ? ? ? clearContent();

? ? ? ? }

? ? ? ? //設(shè)置顯示關(guān)聯(lián)信息的位置

? ? ? ? function setLocaton(){

? ? ? ?

? ? ? ? var content=document.getElementById("keyword");

? ? ? ? var width=content.offsetWidth; //輸入框的距離

? ? ? ? var left=content["offsetLeft"];//距離左邊框的距離

? ? ? ? var top=content["offsetTop"]+content.offsetHeight;//距離頂部距離

? ? ? ? //獲得顯示數(shù)據(jù)的div

? ? ? ? var popDiv=document.getElementById("popDiv");

? ? ? ? popDiv.style.border="black 1px solid";

? ? ? ? popDiv.style.left=left+"px";

? ? ? ? popDiv.style.top=top+"px";

? ? ? ? popDiv.style.width=width+"px";

? ? ? ? document.getElementById("content_table").style.width=width="px";

? ? ? ? }

</script>

</head>

<body>

? ? <div id="mydiv">

? ? ? ? ? <input type="text" size="50" id="keyword" ?onkeyup="getMoreContents()"

? ? ? ? ? onblur="keywordBlur()" onfocus="getMoreContents()"/> ??

? ? ? ? ? <input type="button" value="百度一下" width="50px"/>

? ? ? ? ? <!-- 下面是內(nèi)容展示區(qū)域 -->

? ? ? ? ? <div id="popDiv">

? ? ? ? ? ? ?<table id="content_table" bgcolor="#FFAFA" border="0" cellspacing="0"

? ? ? ? ? ? ? ? ?cellpadding="0">

? ? ? ? ? ? ?<tbody id="content_table_body">

? ? ? ? ? ? ?

? ? ? ? ? ? ? ? ?

? ? ? ? ? ? ? ? ?<!-- 動(dòng)態(tài)查詢的數(shù)據(jù)顯示在這里 -->

? ? ? ? ? ? ? ?<!-- ? ?<tr><td>ajax</td></tr>

? ? ? ? ? ? ? ? ? ? <tr><td>ajax2</td></tr>

? ? ? ? ? ? ? ? ? ? ? <tr><td>ajax1</td></tr> -->

? ? ? ? ? ? ?</tbody>

? ? ? ? ? ? ?

? ? ? ? ? ? ?</table>

? ? ? ? ? </div>

? ? ? </div>

</body>

</html>


0 回復(fù) 有任何疑惑可以回復(fù)我~

我是用eclipse弄得 ??

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

誰有能運(yùn)行的search.jsp的代碼啊,發(fā)一下。我的不能運(yùn)行,只能得到那個(gè)xmlHttp對(duì)象,感激不盡,

我要回答 關(guān)注問題
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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