發(fā)生錯誤200?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>客戶端jQuery</title>
<style>
body,input,button,select,h1{
font-size:30px;
line-height:2px;
}
</style>
</head>
<body>
<h1>員工查詢</h1>
<label>請輸入員工編號:</label>
<input type="text" id="keyword"/>
<button id="search" style="width:80px;height:40px">查詢</button>
<p id="searchResult"></p>
<h1>員工創(chuàng)建</h1>
<label>請輸入員工姓名:</label>
<input type="text" id="staffName" /><br />
<label>請輸入員工編號:</label>
<input type="text" id="staffNumber" /><br />
<label>請輸入員工性別:</label>
<select id="staffSex">
<option>男</option>
<option>女</option>
</select><br />
<label>請輸入員工職位:</label>
<input type="text" id="staffJob" /><br />
<button id="save" style="height:40px">保存</button>
<p id="createResult"></p>
<script src="jquery 1.12.2.js"></script>
<script>
$(document).ready(function(){
$("#search").click(function(){
$.ajax({
type:"GET",
url:"serverjson.php?number="+$("#keyword").val(),
dataType:"json",
success: function(data){
if(data.succcess){
$("#searchResult").html(data.msg);
}else{
$("#searchResult").html("出現(xiàn)錯誤:"+data.msg);
}
},
error:function(jqXHR){
alert("發(fā)生錯誤:"+jqXHR.status);
}
})
})
$("#save").click(function(){
$.ajax({
type:"POST",
url:"serverjson.php",
dataType:"json",
data:{
name:$("#staffName").val(),
number:$("#staffNumber").val(),
sex:$("#staffSex").val(),
job:$("#staffJob").val(),
},
success: function(data){
if(data.succcess){
$("#creatResult").html(data.msg);
}else{
$("#createResult").html("出現(xiàn)錯誤:"+data.msg)
}
},
error:function(jqXHR){
alert("發(fā)生錯誤:"+jqXHR.status);
}
});
});
});
</script>
</body>
</html>
----
為什么我輸入101,點擊查詢,會彈出發(fā)生錯誤200?
為什么信息填寫完整,點擊保存,會顯示出現(xiàn)錯誤呢?
2016-10-28
如果是服務(wù)器沒打開,會報 0. 你把你的php端文件曬出來
2016-08-12
PHP是服務(wù)端的,你直接打開是沒用的,用WAMP打開試試
2016-05-02
dataType:"json",是jsonp
如果url沒改改成你自己的
2016-04-27
請求成功,是服務(wù)器返回的狀態(tài)值