As I mentioned in another question you need to use echo
.
To pass multiple variables you can make an array with them and use echo
combined with json_encode () .
// Variaveis
$nome = $Fetchi['nome'];
$email = $Fetchi['email'];
$tipo = $Fetchi['tipo'];
$senha = "Digite uma nova senha...";
$ativado = $Fetchi['ativado'];
$retorno = array($nome, $email, $tipo, $senha, $ativado);
echo json_encode($retorno);
On the client side (javascript) you should use JSON.parse () like this:
success: function(result){
var resultado = JSON.parse(result);
In this way you will receive an array like this:
[nome, email, tipo, "Digite uma nova senha...", ativado]
To access senha
you can use alert(resultado[3]);
if you want to see all members of the array use: alert(resultado.join('\n'));
You can also pass an object , in some cases it is preferable. So in PHP you need to do this:
$retorno = array('nome'=>$nome, 'email'=>$email, 'tipo'=>$tipo, 'senha'=>$senha, 'ativao'=>$ativado);
echo json_encode($retorno);
In javascript it uses the same JSON.parse () but will receive an object in this format:
{nome: 'valor do nome', email: 'valor do email', tipo: 'valor do tipo', senha: "Digite uma nova senha...", ativao: 'valor do ativao'}
Note: As @jader suggested, also use dataType: json
in AJAX to make it easier to parse the answer.