我正在将一个Laravel项目的API调用到另一个Laravel项目。
我遇到以下错误:
jquery.dataTables.min.js:22未捕获的TypeError:无法读取未定义的属性'DT_RowId'
我尝试提供默认为0和10的偏移量和限制
$limit = 10;
$start =0;
以下是我的项目代码
项目1
public function Jobe(Request $req)
{
$columns = array(
0 => 'jobid',
1 => 'B',
2 => 'C',
3 => 'D',
4 => 'E',
5 => 'F',
6 => 'G',
7 => 'H',
8 => 'I',
9 => 'J'
);
$limit = $req->input('length');
$start = $req->input('start');
$order = $columns[$req->input('order.0.column')];
$sort['dir'] = $req->input('order.0.dir');
$job_pos_id = $req->get('Jobid');
$data = [
'Job_pos_id' => $job_pos_id,
'start' =>$start,
'length' =>$limit,
];
$payload = json_encode($data);
$ch = curl_init();
curl_setopt($ch,
CURLOPT_URL,"http:/localhost/PQWE/public/api/Api");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json',
'Content-Type: application/json'));
curl_setopt($ch, CURLOPT_POSTFIELDS,$payload);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$server_output = curl_exec($ch);
$err = curl_error($ch);
curl_close ($ch);
$totalData=$server_output[0];
$totalFiltered=$server_output[1];
foreach ($server_output as $acc)
{
$nData['jobid'] = $acc['job_pos_id'];
$data[] = $nData;
}
$json_data = array(
"draw" => intval($req->input('draw')),
"recordsTotal" => intval($totalData),
"recordsFiltered" => intval($totalFiltered),
"data" => $data,
"count" => $totalData,
);
return response()->json($json_data);
项目2
public function Api(Request $req)
{
$limit = $req->input('length');
$start = $req->input('start');
$job_pos_id = $req->get('Jobid');
if($job_pos_id == NULL) {
$query = DB::connection('QWEERR')
->table('XYZ')->offset($start)->limit($limit)
->get()->toJson();
$Totaldata= DB::connection('QWEERR')
->table('XYZ')->offset($start)->limit($limit)
->get();
} else {
$query = DB::connection('QWEERR')
->table('XYZ')->where('XYZ.jid','ILIKE',
'%'.$job_pos_id.'%')->get()->toJson();
$Totaldata= DB::connection('QWEERR')
->table('XYZ')->where('XYZ.jid','ILIKE',
'%'.$job_pos_id.'%')->get();
}
$Total=count(Totaldata);
Totalfiltered=$Total;
return response()->json($query,Total,Totalfiltered);
}
获取分页错误,并且在搜索数据未附加错误时获取错误:-未捕获的TypeError:无法读取未定义的属性'DT_RowId'