我正面臨ajax調用的問題。未找到Ajax 404錯誤
這是我LIMK這裏我使用Ajax調用http://www.cholokhai.com/resturant/test-demo/
我在頁腳文件包含的腳本
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
和Ajax調用的代碼是:
jQuery("#next_button").click(function(e){
jQuery(".fetch_data").hide();
jQuery(".booking_confirm").show();
var selected_date = jQuery("#selected_date").text();
var selected_persons = jQuery("#selected_persons").text();
var selected_discount = jQuery("#discount_time").text();
var selected_price = jQuery("#discount_price").text();
var filled_name = jQuery("#selected_name").val();
var filled_email = jQuery("#selected_email").val();
var filled_phone = jQuery("#selected_phone").val();
var postData = 'name='+filled_name+'&email='+filled_email+'&phone='+filled_phone+'&date='+selected_date+'&persons='+selected_persons+'&time='+selected_discount+'&discount='+selected_price;
jQuery.ajax({
url : "http://www.cholokhai.com/ajax",
type: "POST",
data : {v:postData},
dataType: 'json',
success: function(html)
{
jQuery(".booking_confirm").show();
}
});
return false;
});
當即時通訊使用變量不是字符串的數據,如:data {name:filled_name,email:filled_email} 即時通訊404錯誤。
我不知道爲什麼它不工作。 請幫我解決這個問題。 謝謝。
你做錯了。不要以這種方式包含jQuery。它會造成各種問題。使用正確的方法。在這裏看到我的答案如何做到這一點:http://stackoverflow.com/questions/34321767/wordpress-inline-js-cant-get-working/34322445#34322445 –
'404錯誤'意味着''url'是錯誤的.. –
404表示未找到頁面。如果http://www.cholokhai.com是您應用程序的基礎網址,則應該使用:url:「/ ajax」 – DinoMyte