blob: 2a7588983d8cdaf3d85b84414393b3e5c5e62396 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
var last_id = 0;
function searchDirectory() {
var input = document.getElementById("search").value;
if(input){
last_id++;
var request_id = last_id;
var data = new FormData();
data.append("query", input);
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (request_id != last_id) return;
if (this.readyState == 4 && this.status == 200) {
var result_div = document.getElementById("search-results");
result_div.innerHTML = xhttp.responseText;
}
};
xhttp.open("POST", "/directory/search", true);
xhttp.send(data);
}
}
|