0
我正在使用laravel 4.按照jtable的說明,我已經包含了腳本和代碼,但在頁面加載時使用它時,ajax請求被觸發並返回錯誤代碼500.在laravel中使用jtable時發生內部服務器錯誤
路線代碼:
Route::any('/staff',array('as'=>'staff','uses' => '[email protected]'))->before('auth');
查看代碼:
$('#PeopleTableContainer').jtable({
title: 'Table of people',
actions: {
listAction: document.url
},
fields: {
PersonId: {
key: true,
create: false,
edit: false,
list: false
},
Name: {
title: 'Author Name',
width: '40%'
},
Age: {
title: 'Age',
width: '20%'
},
RecordDate: {
title: 'Record date',
width: '30%',
type: 'date',
create: false,
edit: false
}
}
});
$('#PeopleTableContainer').jtable('load');
//If i use {{URL::route('staff',array('action'=>'list')) }} then Ajax is not fired so please also provide solution regading this
Controller Code:
public function getPersons()
{
if(Request::ajax())
{
$row=DB::table('people')->get();
$recordCount=DB::table('people')->count();
$jTableResult = array();
$jTableResult['Result'] = "OK";
$jTableResult['TotalRecordCount'] = $recordCount;
$jTableResult['Records'] =$row;
Response::json($jTableResult);
}
return View::make('backend.staff');
}
所產生的視圖:
人物表 作者姓名 年齡 記錄日期 沒有可用的數據! +添加新紀錄