简体   繁体   English

jQuery DataTable-服务器端处理无响应

[英]JQuery DataTable - Server-side processing not responding

EDIT: Without hard-coding sEcho 编辑:没有硬编码sEcho

在此处输入图片说明

EDIT: 编辑:

<div class="row">
    <div class="col-md-12">
      <div class="panel panel-default">
        <h3 class="panel-heading">Information</h3>
        <div class="panel-body">
          <div class="tab-content">
            <div class="tab-pane active" id="dt_vendor">
              <table id="dt_vendor">
                <thead>
                  <tr>
                    <th>Id</th>
                    <th>Name</th>
                  </tr>
                </thead>
              </table>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>

I have got a JSON object that I receive from a .Net, the JSON object is created as per the specified format. 我有一个从.Net接收到的JSON对象,该JSON对象是根据指定的格式创建的。 But I do not see that its loading the data and I have checked in the Chrome console and I do not see any errors I have got over 15,000 records, what I'm missing and I know it must be very silly 但是我没有看到它正在加载数据,并且我已经在Chrome控制台中进行了检查,也没有看到任何错误,但我有超过15,000条记录,我所缺少的记录,而且我知道它一定很傻

The JSON Object : JSON对象:

在此处输入图片说明

<script>
        $(document).ready(function () {
        $("#dt_vendor").dataTable({    

            "oLanguage": {
                "sZeroRecords": "No records to display",
                "sSearch": "Search..."
            },
            'iDisplayLength': 10,
            "lengthMenu": [ 5, 10, 20, 30, 50, 100 ],
            "bSortClasses": false,
            "bStateSave": false,
            "bPaginate": true,
            "bAutoWidth": false,
            "bProcessing": true,
            "bServerSide": true,
            "bDestroy": true,
            "sAjaxSource": "@Url.Action("GetAjaxData", "Vendor")",
           "bJQueryUI": true,
           "sPaginationType": "full_numbers",
           "bDeferRender": true,

           "fnServerData": function (sSource, aoData, fnCallback) {
               debugger;
               $.ajax({
                   "dataType": 'json',
                   "contentType": "application/json; charset=utf-8",
                   "type": "GET",
                   "url": sSource,
                   "aadata": aoData,
                   "success":
                               function (msg) 
                               {    
                                   var json = jQuery.parseJSON(msg.d);
                                   fnCallback(json);
                                   $("#dt_vendor").show();
                               }
               });
           }

        }); 

        }); 
    </script>

Original Answer 原始答案

Here are a couple of thoughts for your debugging: 这是您调试的一些想法:

  • Are you hard-coding the value of "sEcho" or returning the value provided? 您是否在硬编码“ sEcho”的值或返回提供的值? DataTable uses that to make sure it's processing the response to its latest request. DataTable使用它来确保正在处理对其最新请求的响应。
  • Try providing an empty <tbody> tag inside the <table> simply to ensure that it exists. 尝试在<table>内提供一个空的<tbody>标记只是为了确保它存在。

Solution

Make sure that the value of sEcho included in the response from the .NET code is the same as the value of sEcho provided in the request to the .NET code. 确保.NET代码的响应中包含的sEcho值与.NET代码的请求中提供的sEcho值相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM