我在這裏變得瘋狂。 我正在通過jquery調用同一個域上的腳本,一切都成功,數據在數據庫等,但Ajax仍然給我回錯誤。我試圖用JSON做輸出,沒有幫助。這是昨天剛剛做工精細,但它不是現在的工作...Ajax與jQuery在一切正常時都會返回錯誤
$.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腳本是好的,如果我只是打開地址一切工作正常。有人可以幫助我嗎?這是一種迫切
順便說一句,這是我所得到的(錯誤):{ 「readyState的」 0 「responseText的」: 「」 ,「status」:0,「statusText」:「error」},「error」,「」 – Tom 2012-02-23 03:03:41
php腳本是否有正確的標題?例如'header('Content-type:application/json');' – aletzo 2012-02-23 03:05:32
是否需要json?我會嘗試只是爲了測試設置頁眉 – Tom 2012-02-23 03:08:07