[英]Ajax 404 error not found
I'm facing problem with ajax call. 我遇到了ajax调用问题。
Here is my limk where i'm using ajax call http://www.cholokhai.com/resturant/test-demo/ 这是我使用ajax的电话( 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: 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;
});
When im using variables not string in data like: data{name: filled_name, email: filled_email} im getting 404 error. 当即时通讯使用变量而不是字符串时,数据为:data {name:filled_name,email:filled_email}即时通讯出现404错误。
I don't know why its not working. 我不知道为什么它不起作用。 Please help me to resolve this issue. 请帮助我解决此问题。 Thanks. 谢谢。
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. 与查询字符串参数一样,您正在创建适合URL的字符串,而您需要的是传递json对象。
You can either manually create it or you can parse an object. 您可以手动创建它,也可以解析对象。 bottom line that is not a JSON string. 底线不是JSON字符串。 Have a look at something like this: How can I create a specific JSON string? 看一下这样的东西: 如何创建特定的JSON字符串? , it should help ,应该有帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.