I use the following code to submit a form:
$.ajax({
url: $('#myForm').attr('action'),
url: 'index.php',
type: 'post',
/*dataType: 'html json', *///tell the server that you expect json
data: {
"num" : $('#myNum').val(),
},
success: function(response) {
alert(response);
if ( check_validate() == 1) {
alert(response);
}
else {}
}
});
Then in the PHP index.php
I have:
if (isset($_POST["num"])) {
$num = $_POST["num"];
if($num == 1)
echo "sure!";
}
The JS popups with the sure!
and the whole index.php
page source code. Is there a way to remove the source code and just have the response show without setting the dataType
to JSON
?