Ajax 向服务器发送GET请求。服务器也返回成功结果。
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 选项卡(来自 firebug)
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 选项卡中的全部内容: