【问题标题】:Internal Server Error while using jtable in laravel在 laravel 中使用 jtable 时出现内部服务器错误
【发布时间】:2014-02-15 11:37:18
【问题描述】:

我正在使用 laravel 4。根据 jtable 的说明,我已经包含了脚本和代码,但是在页面加载时使用它时,会触发 ajax 请求并返回错误代码 500。

路线代码:

Route::any('/staff',array('as'=>'staff','uses' => 'HomeController@getPersons'))->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'); 
    } 

生成的视图:

人的表 作者姓名 年龄 记录日期 无可用数据! + 添加新记录

【问题讨论】:

    标签: php json laravel-4 internal-server-error jquery-jtable


    【解决方案1】:

    值得尝试的东西,添加一个循环并从循环中添加到数组中。我不得不为与此非常相似的事情这样做。

    编辑

    也可以看看this:

    我也为此写了tutorial

    【讨论】:

      猜你喜欢
      • 2020-10-07
      • 1970-01-01
      • 2012-11-05
      • 2016-02-09
      • 2014-07-10
      • 2020-02-06
      • 2016-03-02
      • 2015-05-29
      • 2017-10-04
      相关资源
      最近更新 更多