-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.js
More file actions
53 lines (32 loc) · 1002 Bytes
/
main.js
File metadata and controls
53 lines (32 loc) · 1002 Bytes
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
$(document).ready(function() {
$("#searchbox").on("keyup", function() {
var $str = $(this).val();
if($str == "") {
$(".search-results").addClass("hide");
$(".search-results").html("");
} else {
var xhttp;
if (window.XMLHttpRequest) {
xhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.onreadystatechange = function() {
if(this.readyState == 4) {
$(".search-results").removeClass("hide");
$(".search-results").html(this.responseText);
}
$(".search-results li:not(.none)").on("click", function(e) {
$val = $(this).find(".name").html();
$("#searchbox").val($val);
$(".search-results").addClass("hide");
$(".search-results").html("");
$("#search-btn").focus();
})
}
xhttp.open("GET", "searchquery.php?s="+$str, true);
xhttp.send();
}
})
})