I have a problem with 'indexOf'. When i pass a numerical value in argument, it works, but not with a variable:
$.ajax({
url: 'bdd.php',
type: 'POST',
data: {'jsonNomCommune': jsonNomCommune, 'client': client},
success: function(data) {
data = JSON.parse(data);
listClients= data.clients;
listProspects = data.prospects;
$('#tableCSV tbody tr ').each(function(){
var id = $(this).attr('id');
id=id.substring(4);
if (listClients.indexOf(id) > -1){
$(this).css("background-color","red");
}
if (listProspects.indexOf(id) > -1){
$(this).css("background-color","blue");
}
});
}
});
listProspects and listClients are arrays of numericals values. For example, 27 is in listClients, so when id=27, "listClients.indexOf(id) > -1" should works, but it doesn't. And when i write: "(listClients.indexOf(27) > -1)" it works.
Where is the problem??