1
Ajax向服務器發送GET請求。也服務器返回成功的結果。Ajax在服務器返回結果時顯示無響應
Server response:
[{"result":"success"}]
但是ajax沒有顯示任何responseText。 Firebug以紅色顯示獲取請求。
Ajax代碼段:
var params = "&id=" +id + "&phone="+phone + "&account_active=" + activeAccount + "&fname="+fname + "&lname="+lname + "&time_zone="+timezone + "&street="+street+"&suite="+suite+"&ring="+ring+"&city="+city+"&state="+state +"&zip="+zip+"&call_time="+callTime +"&call_length="+callLength+"&call_count="+callCount;
var xmlhttp = getXMLObject();
xmlhttp.open("GET",'agent_manager_response.php?cmd=fsave'+params,true);
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState==4 && xmlhttp.status==200){
var data = eval(xmlhttp.responseText);
if(data[0].result == "success"){
alert('Successfully saved');
}
else{
alert("Error saving data\nError: " + data[0].result);
}
}
}
xmlhttp.send(null);
服務器代碼:
$result = mysql_query($query,$con);
$data=array();
if(!$result)
array_push($data,array('result'=>mysql_error()));
else
array_push($data,array('result'=>'success'));
echo json_encode($data);
Ajax響應DOM標籤(來自螢火蟲)
DONE 4
HEADERS_RECEIVED 2
LOADING 3
OPENED 1
UNSENT 0
getchannel undefined
mozBackgroundRequest false
multipart false
onloadend null
onuploadprogress null
readyState 4
response ""
responseText ""
responseType ""
responseXML null
status 0
getstatusText ""
getupload undefined
withCredentials false
abort abort()
addEventListener addEventListener()
dispatchEvent dispatchEvent()
getAllResponseHeaders getAllResponseHeaders()
getInterface getInterface()
getResponseHeader getResponseHeader()
open open()
overrideMimeType overrideMimeType()
removeEventListener removeEventListener()
send send()
sendAsBinary sendAsBinary()
setRequestHeader setRequestHeader()
Net標籤狀態:
EDITED
這是我的全部淨標籤:
檢查'Net'選項卡並檢查確切的http響應標頭 – 2012-08-15 06:10:13
@Jack感謝您的快速回復。我已添加淨選項卡狀態。我忘了提到一件事,在完整頁面重新加載之後,而不是重新加載一個部分。 – shantanu 2012-08-15 06:18:25
你已經制作了Net標籤的屏幕截圖,但是出現了錯誤的請求;對.php的請求是我所追求的。 – 2012-08-15 06:26:49