簡體   English   中英

找不到Ajax 404錯誤

[英]Ajax 404 error not found

我遇到了ajax調用問題。

這是我使用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錯誤。

我不知道為什么它不起作用。 請幫助我解決此問題。 謝謝。

與查詢字符串參數一樣,您正在創建適合URL的字符串,而您需要的是傳遞json對象。

您可以手動創建它,也可以解析對象。 底線不是JSON字符串。 看一下這樣的東西: 如何創建特定的JSON字符串? ,應該有幫助

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM