I can not get only the JSON string

0

The filter function does not work for me, it says nombredelarray.filter is not a function .

And in the console does not appear a string of% normal string but this:

{…}​abort: function abort()​always: function always()​catch: function catch()​done: function add()​fail: function add()​getAllResponseHeaders: function getAllResponseHeaders()​getResponseHeader: function getResponseHeader()​overrideMimeType: function overrideMimeType()​pipe: function pipe()​progress: function add()​promise: function promise()​readyState: 4​responseJSON: Array [ {…}, {…} ]​responseText: "\r\n[{\"iduser\":\"0\",\"nombre\":\"giuli\",\"pass\":\"giuli\"},{\"iduser\":\"1\",\"nombre\":\"eee\",\"pass\":\"ee\"}]"​setRequestHeader: function setRequestHeader()​state: function state()​status: 200​statusCode: function statusCode()​statusText: "OK"​then: function then()​<prototype>: Object { … } login.js:31:1

Why this error is due, I'm using dataType json and jsonencode en PHP :

function listar(){
  return $.ajax({
    type: "POST",
    url: "../gestionweb/views/procesologin.php",
    data: { "accion": "listarusers"},
    dataType:'json',
    error: function(){
      alert("error petición ajax");
    },
    success: function(data){

    }              
  });
};

Then I do this:

function buscaUser(usuario){
  console.log(usuarios);
  var fil = usuarios.filter(function(e){
    return e.iduser==usuario;
  });
  if (fil.length==0){
    return false;
  }else{
    return true;
  }
}
    
asked by Caruso 24.11.2018 в 13:55
source

0 answers