Why does my success function never runs?
JavaScript:
$.ajax({
url: 'calculation.php',
type: 'POST',
dataType: "json",
data: {
data1: 2,
data2: 3
},
success: function(result){
alert(result);
}
});
PHP:
if(isset($_POST["data1"])){
$dataA = $_POST["data1"];
$dataB = $_POST["data2"];
if(dataA + dataB === 5){
echo "success";
$result = true; //I tried all 3 of these things which it seemed like others did but it still dosen't run.
return $result;
}
}