I am new to jquery and ajax. Is it possible to use ajax in a php script which is returning value?
$.ajax({
url:'ajax.php',
method:'post',
dataType:'json',
success:function(response) {
alert(response);
}
});
In my php script
<?php
$sum = 1+5;
return $sum; //usually echo(json_encode(array("$sum"))); is used
?>
Is this even possible?
P.S I am using return because in the main script this function is called from another function. But for ajax i need only this function.