Hi guys.
I am new here and apprentice jquery.
I am using ajax to send data to a php file, so far so good. the problem is that the ajax does not get the response that comes from php? below follows the scripts:
Jquery:
$(document).ready(function() {
//
$('body').hide();
$('body').fadeIn('slow');
//
$('.data-send').text('Enviar').click(function() {
//
var ws_safe_email = $('.ws_safe_email').val();
//
$.ajax({
type: 'POST',
url: 'datacheck.php',
data: { ws_safe_email: ws_safe_email },
dataType: 'json',
//
beforeSend: function() {
$('.middle-frontstrucs').hide();
$('.middle-frontstrucs').text('Analisando Dados, Aguarde...').fadeIn('slow');
},
//
complete: function() {
},
//
success: function(json) {
var info = json.info;
$('.middle-frontstrucs').html(info).hide();
$('.middle-frontstrucs').html(info).fadeIn('slow');
},
//
error: function() {
}
});
});
});
Php:
<?php header('Content-Type:application/json; Charset=utf-8');
$ws_safe_email = $_POST["ws_safe_email"];
if ($ws_safe_email == '') {
$objreply["info"] = "Email vazio ?";
}
else {
$objreply["info"] = "Email: $ws_safe_email, recebido com sucesso:" ;
}
echo json_encode($objreply);
?>
Note: I used the xdebug and realized that the output in php json format. But (sucess: function) ajax can not capture the php response ?