這是為什么?一直200
<script>
$(document).ready(function(){
$("#search").click(function(){
$.ajax({
type:"GET",
url:"getuser.php?username="+$("#keyword").val(),
dataType:"json",
success:function(data){
if(data.success){
$("#searchResult").html(data.msg);
}else{
$("#searchResult").html("出現(xiàn)錯(cuò)誤"+data.msg);
}
},
error:function(jqXHR){
alert("發(fā)生錯(cuò)誤:"+jqXHR.status);
}
});
});
});
</script>
php代碼
function search(){
if(!isset($_GET["username"])||empty($_GET["username"])){
echo "參數(shù)錯(cuò)誤";
return;
}
$da=new user_dal();
$name=$_GET["username"];
$user1=$da->get_a_username($name);
$info=mysql_fetch_array($user1,MYSQL_ASSOC);
? ? $result="用戶名:".$info['username']."密碼:".$info['password'];
? ??
? ? echo $result;
2017-04-25
剛試了,這個(gè)要在服務(wù)器中運(yùn)行才行,估計(jì)data是充服務(wù)器取出來的,但是可能php沒有編譯出來吧,所以狀態(tài)是200,但是沒有數(shù)據(jù),最后用老師的xamm運(yùn)行了一下出來了,如果直接用webstrom就是顯示的是出現(xiàn)錯(cuò)誤:200
2017-03-17
JS下數(shù)據(jù)是string純文本格式,用的header(“Content-Type”,“text/plain;charset=utf-8”);而jquery下數(shù)據(jù)是json格式,用的應(yīng)該改為header("Content-Type","application/json;charset=utf-8");
希望可以幫到你。
2016-11-28
200表示請(qǐng)求成功呀,一直200說明沒有問題