I have a question about how to do data filtering when the client fills an input field. I'm looking for all server logs (running PHP) through a jQuery JSON request and would like to know how to make a less "restrictive" JavaScript filter since the indexOf () method returns only records for precisely typed values , but when I perform the search directly by query the result is closer than I need. I do not want to use querys to DB very often because of performance issues.
The following is the javascript code (where I get the value entered by the user, and I make the filter in the JSON records):
if( value.nome_produto.indexOf(busca) != -1 ){
tr += '<tr class='_item_em_falta _tr_relative'>
<td> ${value.registro} </td>
<td>
<a href='detalhe.php?codigo=${value.produto_id}'>
<img class='_minha_img' src='${value.imagem_pequeno}'>
</a>
</td>
<td>
<a href='detalhe.php?codigo=${value.produto_id}'>
${value.nome_produto}
</a>
</td>
<td> ${value.preco_produto} </td>
<td> ${value.origem_produto} </td>
<td> ${value.quantidade_total} </td>
<td> ${value.quantidade_vendida} </td>
</tr>';
The indexOf () filter used above only returns products with the same name as the one entered by the user (Case Sensitive and etc). I would like to use a form that allows you to filter the data in a less restrictive way (like the LIKE% example example% command in MySQL)