ajax 调用数据库失败

浏览:559 发布日期:2017/02/19 分类:求助交流 关键字: ajax db
//=======PHP
public function exist_model(){

$idclient = input('idclient');
$name = input('name');
$res = db('model')->where('idclient','=',$idclient)->where('name','=',$name)->find();


if ($res){
return ['txt'=>'BC Name '.$name.'exist','status'=>1];
} else {
return ['txt'=>'BC Name '.$name.' is not exist','status'=>0];
}
}
//========JS ==
function existcheck(){
if ($('#idclient').val()<=0){
alert('Choice Client ');
$('#idclient').focus();
return;
}else{
//检查该名称是否在库中存在
$.ajax({
type:"POST",
url:"exist_model",
datatype:"json",
async:true,
data:{idclient:$('#idclient').val(),
name:$('#name').val()
},
success: function(msg){
if (msg.status==1){
$('#idclient').focus();
alert(msg.txt);
}
},
error: function (res)
{
alert(res.responseText);
return;
}
});
}
}


附件 3.png ( 24.65 KB 下载:1 次 )

最佳答案
评论( 相关
后面还有条评论,点击查看>>