2014-06-19 22 views
-2

當我訪問該頁面時,我剛剛收到「Processing」,但沒有發生任何事情。我看着在鉻控制檯的控制檯,我沒有得到任何錯誤..所以我做錯了什麼,但我不知道它是什麼。起初我以爲這是JSON輸出沒有正確格式化,但我檢查它對jsonlint.comLaravel Datatables不工作,無錯誤

我確定這是簡單的即時通訊過來看...請嗎?

的博客數據控制器

public function data() 
{ 
    $posts = Post::select(array('posts.id', 'posts.title', 'posts.id as comments', 'posts.created_at')); 
    return Datatables::of($posts) 
    ->edit_column('comments', '{{ DB::table(\'comments\')->where(\'post_id\', \'=\', $id)->count() }}') 
    ->add_column('actions', '<a href="{{{ URL::to(\'admin/blog/\' . $id . \'/edit\') }}}" class="btn btn-default btn-xs iframe" >{{{ Lang::get(\'button.edit\') }}}</a> 
      <a href="{{{ URL::to(\'admin/blog/\' . $id . \'/delete\') }}}" class="btn btn-xs btn-danger iframe">{{{ Lang::get(\'button.delete\') }}}</a> 
     ') 
    ->remove_column('id') 
    ->make(); 
} 

的JavaScript:

<table id="posts" class="table table-bordered table-hover"> 
    <thead> 
     <tr> 
      <th>ID</th> 
      <th>Title</th> 
      <th>Content</th> 
      <th>Created</th> 
      <th>{{{ Lang::get('table.actions') }}}</th> 
     </tr> 
    </thead> 
    <tbody> 
    </tbody> 
</table> 
@stop 

@section('scripts') 
<script type="text/javascript"> 
    var oTable; 
    $(document).ready(function() { 
      oTable = $('#posts').dataTable({ 
      "sDom": "<l><f><r>t<i><p>", 
      "sPaginationType": "bootstrap", 
      "oLanguage": { 
       "sSearch": "Search:", 
       "sLengthMenu": "_MENU_ records per page" 
      }, 
      "bProcessing": true, 
      "bServerSide": true, 
      "sAjaxSource": "{{ URL::to('admin/blog/data') }}" 
     }); 

     $("#users_filter input").addClass("form-control inline-control input-sm"); 
     $("#users_length select").addClass("form-control inline-control"); 
    }); 
</script> 
@stop 

UPDATE: 數據表只是罰款在我的本地,但只要我拉回購到我的生產服務器不起作用。

這裏是JSON數據

{"sEcho":0,"iTotalRecords":2,"iTotalDisplayRecords":2,"aaData":[[1,"First Post","<p>Welcome to my new blog. It&#39;s still under development and there are constantly changes being made. Just today i got CKEditor working on my blog admin, so that i could put HTML into my posts. Thi...<\/p>","1","2014-06-08 04:12:14","<a href=\"http:\/\/www.asdasd.com\/admin\/blog\/1\/edit\" class=\"btn btn-default btn-xs iframe\" >Edit<\/a>\n    <a href=\"http:\/\/www.asdaf.com\/admin\/blog\/1\/delete\" class=\"btn btn-xs btn-danger iframe\">Delete<\/a>\n   "],[2,"second","yep its working","1","2014-06-08 05:58:13","<a href=\"http:\/\/www.asdaf.com\/admin\/blog\/2\/edit\" class=\"btn btn-default btn-xs iframe\" >Edit<\/a>\n    <a href=\"http:\/\/www.asdaf.com\/admin\/blog\/2\/delete\" class=\"btn btn-xs btn-danger iframe\">Delete<\/a>\n   "]],"sColumns":["posts.id","posts.title","posts.content","posts.id as comments","posts.created_at","actions"],"aQueries":[{"query":"select * from `users` where `id` = ? limit 1","bindings":[1],"time":1.1},{"query":"select `roles`.*, `assigned_roles`.`user_id` as `pivot_user_id`, `assigned_roles`.`role_id` as `pivot_role_id` from `roles` inner join `assigned_roles` on `roles`.`id` = `assigned_roles`.`role_id` where `assigned_roles`.`user_id` = ?","bindings":[1],"time":0.99},{"query":"select `posts`.`id`, `posts`.`title`, `posts`.`content`, `posts`.`id` as `comments`, `posts`.`created_at` from `posts`","bindings":[],"time":3.98},{"query":"select count(*) as aggregate from `comments` where `post_id` = ?","bindings":[1],"time":2.34},{"query":"select count(*) as aggregate from `comments` where `post_id` = ?","bindings":[2],"time":0.73}]} 

這裏是應用程序/存儲/日誌/日誌CGI-FCGI-2014-06-21.txt

[2014-06-21 22:19:30] production.INFO: index [] [] 
[2014-06-21 22:19:31] production.INFO: data [] [] 
+0

你使用什麼軟件包? – Kryten

+0

bllim/laravel4-datatables-package – brandenwagner

+0

當你直接在瀏覽器中訪問「admin/blog/data」時會得到什麼? – Unnawut

回答

0

我想通了問題。我有2個不同版本的datatable.js文件。我猜測變量覆蓋彼此...但只要我升級所有的相同版本,它正在工作。