I have a headache that is as follows: I need to do a filter by names of the following JSON (summarized) ...
[
{
"index": 0,
"age": 25,
"eyeColor": "green",
"name": "Peck Murphy",
"gender": "male",
"company": "MEDICROIX",
"email": "[email protected]",
"phone": "+1 (992) 428-2202",
"address": "219 McDonald Avenue, Tioga, Utah, 6059"
},
{
"index": 1,
"age": 29,
"eyeColor": "blue",
"name": "Rosalyn Mckay",
"gender": "female",
"company": "COREPAN",
"email": "[email protected]",
"phone": "+1 (927) 507-3490",
"address": "537 Rost Place, Thynedale, Wyoming, 5160"
}
]
The ideal would be to filter it by name. It sounds simple, but my task is to do this filter from the same JSON, only from an external link, which is this one , and then put the rows that passed the filter in a table.
My question is how do I filter this JSON that is online for a value entered in a text box and show all the data of the line that passed through the filter? I'll turn the entire jQuery manual and nothing to save me. If anyone can give me a light, I will be very grateful.
The latest jQuery script I've done:
$(document).ready(function () { // Filtro único para nome
$('#Cons_Name').keyup( function () { // Cons_Name é a id de um input que o usuário insere o nome de alguém para filtro
var json = $.getJSON('https://quarkbackend.com/getfile/gcpolidoro/data-json', function(data) {
var arr = $("td").filter(function (ret, i) {
return ret.name == $("#Cons_Name").val();
})
console.log(arr);
});
});
});