Get the App
SLTechnology News&Howtos  ›  Development  › 

How to achieve the effect of imitating Google Suggest by AJAX

Shulou Source: shulou.com Published: 2022-06-03 08:36:25 09月30日 Update

This article mainly shows you "AJAX how to achieve imitating Google Suggest effect", the content is easy to understand, clear, hope to help you solve doubts, the following let the editor lead you to study and learn "AJAX how to achieve imitating Google Suggest effect" this article.

The code is as follows:

Paramecium-simple Google Suggest

Suggest.js

The code is as follows:

Var jungle Musi 1

Var temp_str

Var $= function (node) {

Return document.getElementById (node)

}

Var $$= function (node) {

Return document.getElementsByTagName (node)

}

Function ajax_keyword () {

Var xmlhttp

Try {

Xmlhttp=new XMLHttpRequest ()

}

Catch (e) {

Xmlhttp=new ActiveXObject ("Microsoft.XMLHTTP")

}

Xmlhttp.onreadystatechange=function () {

If (xmlhttp.readyState==4) {

If (xmlhttp.status==200) {

Var data=xmlhttp.responseText

$("suggest") [xss_clean] = data

Jackpot Musi 1

}

}

}

Xmlhttp.open ("post", "ajax_result.asp", true)

Xmlhttp.setRequestHeader ('Content-type','application/x-www-form-urlencoded')

Xmlhttp.send ("keyword=" + escape ($("keyword") .value))

}

Function keydeal (e) {

Var keyc

If (window.event) {

Keyc=e.keyCode

}

Else if (e.which) {

Keyc=e.which

}

If (keycages 40 & & keycages 38) {

Ajax_keyword ()

Temp_str=$ ("keyword"). Value

}

If (keyc==40 | | keyc==38) {

If (keyc==40) {

If (jacks $("li") .length) {

Jackpot Musi 1

}

}

If (j > = $("li") .length) {

Jackpot Musi 1

}

}

If (keyc==38) {

If (j > = 0) {

Jmuri-

If (jacks 0 & & j

Tags: Effects content articles code learning help easy to understand more organization knowledge simplicity ribbon paramecium industry information information channels channels research Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Microsoft NVidia Docker Huawei