There is a filter.
The filter filters by the "full name" field. Everything works.
Logic:
- the user enters the criteria for the filter in <input id="fio">
- criteria fall into JS
- data is received from the database
- the HTML table is stored.
How to set up a filter for conditions:
- there is no data in the database according to criteria. Result: we get a message on the page - "No results";
- The user has cleared <input id="fio">. Result: The entire table is displayed.
I try to do it, but nothing happens.
The filter filters by the "full name" field. Everything works.
Logic:
- the user enters the criteria for the filter in <input id="fio">
- criteria fall into JS
- data is received from the database
- the HTML table is stored.
How to set up a filter for conditions:
- there is no data in the database according to criteria. Result: we get a message on the page - "No results";
- The user has cleared <input id="fio">. Result: The entire table is displayed.
I try to do it, but nothing happens.
JavaScript:
// Filter --- --- --- --- --- --- --- --- --- ---
$('# fio').on('input', function () {
var criteria = fio.value;
// event.preventDefault();
$.ajax({
url: "http://localhost:2000/players/getByFio ",
method: "POST",
data: { criteria: criteria },
data type: "JSON",
success: function (data) {
var html = ";
var dataState = data.length;
if (data.length > 0) {
Assembly records(data);
} // if (data length > 0) {
otherwise, if (data.length = 0) {
var html = ";
} // if (data.length = 0) {
otherwise, if (criterion.length = 0) {
loadAllData();
} // if (data.length = 1) {
} // success: function (data) {
});
});