Php 未找到Ajax 404错误

Php 未找到Ajax 404错误,php,jquery,ajax,wordpress,Php,Jquery,Ajax,Wordpress,我面临ajax调用的问题 这是我使用ajax调用的地方 我已经在页脚文件中包含了脚本 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> 当我在数据中使用变量而不是字符串时,比如:data{name:filled_name,email:filled_email} 我收到404错误 我不知道为什么它不起作用。 请帮我解决这个问题。 谢谢。您正在使用

我面临ajax调用的问题

这是我使用ajax调用的地方

我已经在页脚文件中包含了脚本

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
当我在数据中使用变量而不是字符串时,比如:data{name:filled_name,email:filled_email} 我收到404错误

我不知道为什么它不起作用。 请帮我解决这个问题。
谢谢。

您正在使用查询字符串参数创建适合URL的字符串,而您需要的是传递json对象


您可以手动创建它,也可以解析对象。不是JSON字符串的底线。看一看这样的东西:,它应该会有帮助

你做错了。不要以这种方式包含jQuery。它会引起各种各样的问题。用正确的方法。请参阅我在这里关于如何操作的答案:
404错误
表示
url
错误……404表示找不到页面。如果是应用程序的基本url,则只需使用:url:“/ajax”在WordPress中的ajax是经过专门设计的。我强烈建议您阅读这篇文章:和/或这篇文章:您正在格式化要发送的数据,就像它是url的一部分一样。您应该将其作为序列化json对象发送。我使用ajax调用url,其中resturant是我的自定义帖子类型。测试演示是我的帖子
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;
    });