guichet/static/javascript/search.js
darkgallium 59c29e9c76
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
show everyone in the directory page by default
2021-08-18 12:44:44 +02:00

22 lines
618 B
JavaScript

var last_id = 0;
function searchDirectory() {
var input = document.getElementById("search").value;
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);
}