diff options
Diffstat (limited to 'static/javascript/search.js')
-rw-r--r-- | static/javascript/search.js | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/static/javascript/search.js b/static/javascript/search.js index 9e078be..6d33fe6 100644 --- a/static/javascript/search.js +++ b/static/javascript/search.js @@ -1,4 +1,5 @@ var perso_id = 0; +var last_id = 0; function searchDirectory() { var input = document.getElementById("search").value; @@ -10,8 +11,8 @@ function searchDirectory() { //Response from Request Ajax var jsonResponse = JSON.parse(xhttp.responseText); - if (perso_id < jsonResponse.id) { - perso_id = jsonResponse.id + if (last_id < jsonResponse.id) { + last_id = jsonResponse.id //We get the old table element, we create an new table element then we increment this new table. //After the new add, we replace the old table by the new one. var old_table = document.getElementById("users"); @@ -29,19 +30,16 @@ function searchDirectory() { identifiant.innerHTML = `<a href="/admin/ldap/${jsonResponse.search[i].dn}">${jsonResponse.search[i].identifiant}</a>` name.innerHTML = jsonResponse.search[i].name email.innerHTML = jsonResponse.search[i].email - description.innerHTML = `${jsonResponse.search[i].description}` + description.innerHTML = jsonResponse.search[i].description } old_table.parentNode.replaceChild(table, old_table) } } }; + perso_id += 1 xhttp.overrideMimeType("application/json"); - xhttp.open("GET", "/search/".concat(input), true); - xhttp.send(); + xhttp.open("POST", "/search/".concat(input), true); + xhttp.send(JSON.stringify({"id": perso_id})); } - - - - }
\ No newline at end of file |