Reputation: 2726
I am calling AJAX by jQuery to the script on the same domain, everything is successful, data are in the database etc, but AJAX still gives me back error. I tried to do output in JSON, didn't help. It was working just fine yesterday, but it's not working now.
$.ajax({
url: "http://www.thirst4water.org/api/?request=sign_petition"+query_string,
success: function(data){ // Ajax successfull
alert('Request successful and id is'+data);
// Hide loader
$('.join-us .loader').hide();
// If return is numeric we have id, if not we have error
if (isNumber(data)){
window.userId = data; // Save gobally new user id
$('.join-us').fadeOut(); // Hide the Signing form
// If we have userPic that means user came from facebook, and can skip uploading of picture
if(window.userPic){
// Store avatar from facebook
tomUploadAvatar(window.userPic);
// Switch the steps
$('#step2').fadeOut('normal',function(){
$('#step3').fadeIn(); // Let's see the final step
});
// And re-load the dragon
tomReloadDragonPerson(window.userId);
} else {
$('.join-us').fadeOut('normal',function(){ // Hide the Signing form
$('#step2').fadeIn(); // In case we didnt come from facebook we show uploading form
});
}
} else {
$('.join-us .actions').html(data);
}
},
error: function(value1,value2,value3){
alert(JSON.stringify(value1)+JSON.stringify(value2)+JSON.stringify(value3));
},
});
return false;
});
The PHP script is fine, if I just open the address everything works fine.
Upvotes: 4
Views: 392
Reputation: 1150
Try changing this
url: "http://www.thirst4water.org/api/?request=sign_petition"+query_string,
success: function(data){ // Ajax successfull
to this
url: "http://www.thirst4water.org/api/?request=sign_petition"+query_string,
dataType: "json",
success: function(data){ // Ajax successfull
Upvotes: 1