ajax php 错误提示,ajax收集PHP错误

用户提问

代码如下

if($_GET['action']=="baocun"){

$dadb = stripslashes(trim($_POST['data']));

//if(empty($lfjuid))die("Forbidden!");

$arr = explode(".",$dadb);

$uid = $lfjuid;

$time = time();

$cid = stripslashes(trim($_POST['cid']));

$data = json_encode($arr);

$rsdb1 = $db->get_one("SELECT * FROM `{$pre}newdiy` WHERE uid='{$lfjuid}' && cid='{$cid}'");

//print_r($rsdb);

if($rsdb1){

$sql = "UPDATE `{$pre}newdiy` SET time='$time',data='$data' WHERE uid='{$lfjuid}'";

if($db->query($sql)){

$arr['success'] = "1";

$arr['mag'] = "OK!update";

}else{

$arr['success'] = "2";

$arr['mag'] = "ERRO!update";

};

}else{

$sql = "REPLACE INTO `{$pre}newdiy` (`uid` , `cid`, `data` , `time` ) VALUES ('$uid','$cid','$data','$time')";

$db->query($sql);

if($db->query($sql)){

$arr['success'] = "1";

$arr['mag'] = "OK!into";

}else{

$arr['success'] = "2";

$arr['mag'] = "ERRO!into";

};

}

echo json_encode($arr);

}

如果数据库报错时ajax那边如何提示数据库报错

推荐答案

$.ajax({

success:function(){},

error:function(){}

});