Estoy aprendiendo a usar Ajax en Jquery y no tengo idea de cómo mostrar el contenido que recibo de PHP. En el archivo php, solo estoy haciendo algunos cálculos y estoy haciendo eco del resultado (¿debería devolverlo en su lugar?), Pero el código a continuación no devuelve nada. No pasa nada, el div permanece vacío. Este es mi código php:
$totaalPrice = $totaal; $roundUp = number_format($totaalPrice, 2, '.', ''); $replace = str_replace(".", ",", $roundUp); echo "Uw rit kost: € " . $replace . " euro<br>"; Así es como construí mi 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..');} }); $.ajax({ type: "POST", url: "brain.php", data: {km:km, time:time, day:day}, success: function(price){ $('#showPrice').html(price); }, error: function(){ alert('something went wrong..');} });