Reputation: 65
Can't able to figure out, why this jquery function always returns an error instead of success.
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:
{"result":true}
Upvotes: 1
Views: 93
Reputation: 173
It`s a cross domain error. If you run the js code on crome console you can see the error
XMLHttpRequest cannot load http://www.zwembad.eu/ajax_push_order_status_request.php. Origin http://zwembad.eu is not allowed by Access-Control-Allow-Origin.
Upvotes: 0
Reputation: 27351
Your ajax call is to a different domain (the site is on zwembad.eu
while the ajax call goes to 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.
Upvotes: 1
Reputation: 22721
Can you make sure the url
is in right path.
url : 'ajax_push_order_status_request.php', // use this if it is same dir
Upvotes: 0