![](/img/trans.png)
[英]How to display a .php file with Ajax using JQuery from a dropdown list?
[英]How to display data from PHP using Jquery Ajax?
我正在學習如何在 Jquery 中使用 Ajax,我不知道如何顯示我從 PHP 收到的內容。在 php 文件中,我只是在做一些計算,我正在回應結果(我應該返回它代替?),但下面的代碼不返回任何東西。 沒有任何反應 div 保持為空。 這是我的 php 代碼:
$totaalPrice = $totaal;
$roundUp = number_format($totaalPrice, 2, '.', '');
$replace = str_replace(".", ",", $roundUp);
echo "Uw rit kost: € " . $replace . " euro<br>";
這就是我構建 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..');}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.