I'm learning how to use Ajax in Jquery and I have no idea how to display the content that I receive back from the PHP. In the php file I'm just doing some calculations and I'm echoing the result (should I return it instead?), but the code below doesn't return anything. Nothing happens the div stays empty. This is my php code:
$totaalPrice = $totaal;
$roundUp = number_format($totaalPrice, 2, '.', '');
$replace = str_replace(".", ",", $roundUp);
echo "Uw rit kost: € " . $replace . " euro<br>";
This is how I built my Ajax:
$.ajax({
type: "POST",
url: "brain.php",
data: {km:km, time:time, day:day},
succes: function(price){
$('#showPrice').html(price).show(price); //This where I'm trying to display the result.
},
error: function(){
alert('something went wrong..');}
});
succesvssuccessconsole.log(price)/your browsers DevConsole to see what you get from that request