1
I’m making the login screen using getJSON
. I’d like to know how I can do the redirect once it’s successful.
The idea of redirecting login.php
is not to get too exposed the Javascript code.
login file.PHP
$Array[] = Array(
"sucesso" => "<script>window.location='painel.php'</script>",
);
$json_encode = json_encode($Array);
echo $json_encode;
INDEX.PHP file
$("#acessar").click(function() {
usuario = $("#usuario").val();
senha = $("#senha").val();
// carregamos o JSON passando o nome
$.getJSON("login.php", {usuario:usuario, senha:senha}, function(json){
json[0].sucesso;
});
});
Sam, is giving internal error in the server when use
location.href = json[0].sucesso;
– Tiago
There should be no server error, because this code is Javascript.
– Sam
I decided, inside the
getJSON
I have aIF
that checks whether returned successfully or not. I put in theelse
and it worked.– Tiago