My code looks like this:
sendAjax(new FormData(this), function(retorno) {
if(retorno.isArray)
{
$(".erro-login strong").text("ID: " + retorno.id + " usuário: " + retorno.usuario);
$(".erro-login").show("slow");
navigator.notification.beep(1);
}
else
{
$("input[name = usuario]").val(retorno);
$(".erro-login strong").text(retorno);
$(".erro-login").show("slow");
navigator.vibrate(1);
}
});
The variable retorno
can be of type String
or a Array JSON
, I want to know how do I differentiate this in Jquey
? I tried to use isArray
but it did not work, it keeps entering else
with the return value for example:
{
"tipo":1,
"usuario":"Guilherme",
"key":"66bd30f0cf4309c4ad7308fff5efffe8"
}
In short, how to differentiate a variable when it is JSON or String?