Why does not this function work in Mobile Browser?

1

I'm using the code below to search data in a json, and works perfectly in Chrome and Firefox, but in mobile browser it does not work, and simply does not return anything:

function searchTitles(e){
    var val = decodeURI(e);

    var data = Object.values(meu_json).filter(function(objecto) { 
        return objecto.titulo.toLowerCase().indexOf(val.toLowerCase()) > -1 
    });
    if(data == ""){
        var data = Object.values(meu_json).filter(function(objecto) { 
            return objecto.categoria.toLowerCase().indexOf(val.toLowerCase()) > -1 
        });
    }
    if(data != ""){
        alert(data);
    }else {
        alert('error');
    }   
}

When using in chrome or firefox, it returns the data and data != "" but the same in a mobile browser, it does not work, it just does not happen, there is no error message.

    
asked by anonymous 06.02.2017 / 12:12

1 answer

0

Maybe the problem is Object.values , you can try replacing it with for..in :

var valores = [];
for (property in meu_json){
  valores.push(meu_json[property]);
}

var data = valores.filter(function(objecto) { 
    return objecto.titulo.toLowerCase().indexOf(val.toLowerCase()) > -1 
});
    
06.02.2017 / 14:05