-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
39 lines (37 loc) · 945 Bytes
/
search.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<html>
<head>
<script>
function showResult(str) {
if (str.length<=3) {
document.getElementById("livesearch").innerHTML="";
document.getElementById("livesearch").style.border="0px";
return;
}
if (window.XMLHttpRequest) {
xmlhttp=new XMLHttpRequest();
} else {
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
console.log(str);
if(xmlhttp.readyState == 0 || xmlhttp.readyState == 4)
{
str = encodeURIComponent(str)
xmlhttp.open("GET","livesearch.php?search="+str,true);
xmlhttp.onreadystatechange=function() {
if (this.readyState==4 && this.status==200) {
document.getElementById("livesearch").innerHTML=this.responseText;
document.getElementById("livesearch").style.border="1px solid #A5ACB2";
}
}
xmlhttp.send();
}
}
</script>
</head>
<body>
<form action="livesearch.php">
<input type="text" size="30" l>
<div id="livesearch"></div>
</form>
</body>
</html>