Currently I am having issue with returning some values from PHP to jQuery - not sure how to do it
$(document).ready(function(){
$('#testForm').submit(function(e){
$.post('submit.php',$(this).serialize(),function(msg){
$('#submit').val('Submit');
if(msg.status){
$('#testForm').html(msg);
}
else {
$('#testForm').html("fail");
}
},'json');
});
});
<?php
$name = $_POST['name'];
$email = $_POST['email'];
//echo json_encode(array('status'=>1,'html'=>$name." : ".$email));
echo '{"status":1,'.$name.'}';
?>
I would like to return the name
variable value from PHP to jQuery once status = 1
means success, but I'm still having no luck in doing it.