I have the following response in jSon
received from a php
file.
{"1":"OK","2":"n"}
I now want to get the values from the indexes jQuery
and 1
, which are respectively 2
and "OK"
. >
How to do this?
My block looks like this:
$("a#bloqDesbloq").click(function() {
$.post ("../_requeridos/alteraAdministrador.php", {
idAdministrador : $(this).attr('idAdmin'),
bloq : $(this).attr('bloq')
}, function(retorno){
alert(retorno[1]);
if (retorno[1] == "OK") {
if (retorno[2] == "s") $("a#bloqDesbloq img").prop("src",'_img/desbloquear.png')
if (retorno[2] == "n") $("a#bloqDesbloq img").prop("src",'_img/bloquear.png')
location.reload();
} else {
alert("Erro no bloqueio");
location.reload();
}
}
);
return false;
});
Doing:
alert(retorno[1]);
Only return double quotes
"