0
When I do so, the return is a parsererror.
$.ajax({
type: "GET",
url: "servicos.php",
data: "id=1",
dataType: 'json', ==========================> Essa linha bem aqui
success: function(retorno,status){
// retorno = JSON.parse(retorno);
$("#tudo").html(retorno);
},
error: function(retorno,erro){
$("#tudo").html(retorno.responseText);
}
});
Only gives Success if remove this line or leave as 'text'.
However (still leaving dataType: 'json'), when I ask to return the error of this fomra:
error: function(retorno,erro){
$("#tudo").html(retorno.responseText);
}
I get the same Success result without "dataType: 'json'"
I didn’t understand that.
What is this PHP returning? Are you sure it is a valid JSON?
– bfavaretto
Another thing is that jQuery tries to parse json alone, even without declaring the datatype. So it could just be that, the return argument is already an object, you can use directly from your callback.
– bfavaretto
the return looks something like this: [{"id":"1","name":"Juca","status":"1"}]
– bur
Friend I tested here and it worked,just by replacing dataType by datatype
– Jhonny de farias