[英]jquery ajax call returning error
Can't able to figure out, why this jquery function always returns an error instead of success. 不能弄清楚,为什么这个jquery函数总是返回错误而不是成功。
So I hope to get some feedback ;-) 所以我希望得到一些反馈;-)
Thanks in advance! 提前致谢!
Bas 巴斯
$.ajax({
type : 'POST',
dataType: 'json',
url : '/ajax_push_order_status_request.php',
data: dataString,
success:function (data) {
$('.success').fadeIn(1000);
$(".success").append(data);
},
error: function (data) {
alert( "ERROR: " + data );
$('.error1').fadeIn(1000);
}
});
My PHP script returns: 我的PHP脚本返回:
{"result":true}
Your ajax call is to a different domain (the site is on zwembad.eu
while the ajax call goes to www.zwembad.eu
). 您的ajax调用是到另一个域的(该站点位于
zwembad.eu
而ajax调用则访问www.zwembad.eu
)。 You'll need to use jsonp instead of json and set the Access-Control-Allow-Origin
header correctly, or make sure you make the ajax call on the same domain. 您将需要使用jsonp而不是json并正确设置
Access-Control-Allow-Origin
标头,或确保在同一域上进行ajax调用。
您能确定url
在正确的路径吗?
url : 'ajax_push_order_status_request.php', // use this if it is same dir
It`sa cross domain error. 这是跨域错误。 If you run the js code on crome console you can see the error
如果在crome控制台上运行js代码,则可以看到错误
XMLHttpRequest cannot load http://www.zwembad.eu/ajax_push_order_status_request.php . XMLHttpRequest无法加载http://www.zwembad.eu/ajax_push_order_status_request.php 。 Origin http://zwembad.eu is not allowed by Access-Control-Allow-Origin.
Access-Control-Allow-Origin不允许使用来源http://zwembad.eu 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.