weixin_33724659 2015-12-17 17:42 采纳率: 0%
浏览 29

找不到Ajax 404错误

I'm facing problem with ajax call.

Here is my limk where i'm using ajax call http://www.cholokhai.com/resturant/test-demo/

I have included script in footer file

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>

and code of ajax call is:

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;
    });

When im using variables not string in data like: data{name: filled_name, email: filled_email} im getting 404 error.

I don't know why its not working. Please help me to resolve this issue. Thanks.

  • 写回答

1条回答 默认 最新

  • weixin_33688840 2015-12-17 18:01
    关注

    You are creating a string fit for a URL as in with Query String parameters while what you need is to pass a json object.

    You can either manually create it or you can parse an object. bottom line that is not a JSON string. Have a look at something like this: How can I create a specific JSON string?, it should help

    评论

报告相同问题?