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 次 )
最佳答案