【问题标题】:Laravel datatables error on default search默认搜索时的 Laravel 数据表错误
【发布时间】:2015-02-06 15:50:21
【问题描述】:

让我的数据表运行良好,但是如果我使用默认搜索框,则会出现以下错误。我看不出我在哪里解决这个问题,因为我认为这应该可以解决问题。

我不想配置任何自定义搜索。是我破坏了它还是这是一个错误?

错误

DataTables warning: table id=loadBookings - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1

jQuery

$(document).ready(function () {
    $('#loadBookings').dataTable( {
        "bProcessing": true,
        "bServerSide": true,
        "sAjaxSource": "{{ URL::to('api/bookings') }}",
        "autoWidth": false,
        "aaSorting": [[ 3, "desc" ]],
        "aoColumns": [
                { 'sWidth': '40px', "bSearchable": true},
                { "sWidth": "75px", "bSearchable": true},
                { 'sWidth': '80px', "bSearchable": true},
                { 'sWidth': '35px', "bSearchable": true},
                { 'sWidth': '35px', "bSearchable": true},
                { 'sWidth': '55px', "bSearchable": true}
            ],
        "sPaginationType": "full_numbers"
    });

});

JSON

{

"sEcho": 0,
"iTotalRecords": 1,
"iTotalDisplayRecords": 1,
"aaData": [
    {
        "0": "Title",
        "1": "Name",
        "2": "Joe Smith",
        "3": "Accepted",
        "4": " 07 Oct 2015",
        "5": " <a href="">Update</a>",
        "6": "Item 1",
        "7": "Accepted",
        "DT_RowClass": "accepted"
    }
],
"sColumns": [
    "bookings.id",
    "bookings.title",
    { },
    "bookings.location",
    "bookings.id",
    "bookings.time_id",
    "user.name as user_name",
    "bookings.start",
    "bookings.end",
    "bookings.user_id",
    "title",
    "actions"
]

}

【问题讨论】:

  • 请发URL::to('api/bookings')的样品退货
  • 谢谢,已用 JSON 更新

标签: jquery laravel laravel-4 jquery-datatables


【解决方案1】:

从您的 JSON 中检查:

"5": " <a href="">Update</a>", // INVALID JSON

应该是"5": " &lt;a href=\"\"&gt;Update&lt;/a&gt;","5": " &lt;a href=''&gt;Update&lt;/a&gt;",

【讨论】:

  • 出于提问的目的,我取出了一些敏感信息。我很可能添加了流氓角色。
  • 只需更改敏感信息即可。请再发一次
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-08-18
  • 2022-01-03
  • 1970-01-01
  • 1970-01-01
  • 2017-05-31
  • 2015-05-31
  • 2019-02-05
相关资源
最近更新 更多