Problems ajax jquery

0
var ajax = $.ajax({
    method: "GET",
    url: "api/fichas",
    dataType: "json",
    success: function( strData ){
        alert("work");
        $("#agenda .content").append(strData);
    }
}).done(function(){
    console.log("WORK");
});

I have this code in a button, it makes the request but it does not show anything, neither error nor that it is already done (the function .done ())

    
asked by Hector Seguro 17.01.2017 в 21:52
source

1 answer

1

The answer of api/fichas should be in JSON format, if it finds errors in the content and it is not of the json type, the response function success , .done() will not be called, instead it would call .fail ()

//codigo
}).fail(function(response, error){
  console.log(error); //si retorna 'parseerror', api/fichas no está devolviendo un formato JSON correcto
})
    
answered by 17.01.2017 / 21:58
source