前台Cate下的index页面:
$.ajax({
type: 'POST',
// url: '{:url("baseinfo/product/lastPId")}?f2='+f2,
url: '__ROOT__/baseinfo/product/lastPId?f2='+f2,
dataType: 'json',
success: function(data){
alert("success");
},
error:function(data, form) {
alert("error");
},
complete:function(data){
alert("complete");
}
});访问后台Product控制器下的lastPId方法public function lastPId(Request $request, $f2){
Util::debug($f2);
$status = 0;
$msg = '查找失败.';
$result = null;
$newPId =null;
try{
$result = LastnumModel::get(['name'=>'category_product', 'sub_name'=>$f2]);
if(true == $result ){
$status = 1;
$msg = '查找成功.';
}
}catch(\Exception $e){
$msg = $msg.'数据库错误.';
Util::error($e->getMessage());
}finally{
return json(['status'=>$status, 'msg'=>$msg, 'f2'=>$f2]);
}
} 最佳答案