我通过jQuery调用AJAX到同一个域的脚本,一切都成功,数据在数据库等,但AJAX仍然给我回错.我试着用JSON做输出,没有帮助.它昨天工作得很好,但它现在没有用.
$.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;
});
PHP脚本很好,如果我只是打开地址一切正常.
解决方法:
尝试改变这个
url: "http://www.thirst4water.org/api/?request=sign_petition"+query_string,
success: function(data){ // Ajax successfull
对此
url: "http://www.thirst4water.org/api/?request=sign_petition"+query_string,
dataType: "json",
success: function(data){ // Ajax successfull
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。