【问题标题】:DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error. (ASP.NET)DataTables 警告:无法解析来自服务器的 JSON 数据。这是由 JSON 格式错误引起的。 (ASP.NET)
【发布时间】:2013-03-07 20:48:51
【问题描述】:

我正在使用 ASP.NET VS2010 和 C#.NET 作为后端语言,我没有使用 MVC。 我在从服务器端加载数据时遇到问题。它显示正确的行数但没有数据。我的 JSON 响应是有效的 Json 字符串。

任何人都知道如何解决这个问题???????

这是我得到的响应字符串

{"sEcho": 1,"iTotalRecords": 2,"iTotalDisplayRecords": 2,"aaData": [{"Name":"IT","DescEn":"Information Technology","DescAr":"testing","CreatedOn":"18-03-2013","CreatedBy":"1"},{"Name":"HR","DescEn":"Human Resource","DescAr":"testing","CreatedOn":"18-03-2013","CreatedBy":"1"}]}

这里是html

<table id='example' class="datatable">
                <thead>
                    <tr>
                        <th>
                            Name
                        </th>
                        <th>
                            DescEn
                        </th>
                        <th>
                            DescAr
                        </th>
                        <th>
                            CreatedOn
                        </th>
                        <th>
                            CreatedBy
                        </th>
                    </tr>
                </thead>
                <tbody>
                </tbody>
            </table>

这是一个JS脚本

$(document).ready(function () {
            var oTable = $('#example').dataTable({
                "bProcessing": true,
                "bServerSide": true,
                "bDestroy": true,
                "sPaginationType": "full_numbers",
                "aaSorting": [[1, "desc"]],
                "sAjaxSource": '<%= Page.ResolveClientUrl("Request/GroupPage.aspx") %>',
                "aoColumns": [
           { "aaData": "Name" },
            { "aaData": "DescEn" },
            { "aaData": "DescAr" },
            { "aaData": "CreatedOn" },
            { "aaData": "CreatedBy" }
        ]
            });
        });

任何人都知道如何解决这个问题??????

【问题讨论】:

  • 如何在后端序列化对象?你得到的转义字符串作为 json 无效
  • 我正在从数据库中读取数据,然后将该数据保存在 C# 字符串中,以便在我需要使用转义序列的单词的两侧进行引用
  • 所以你将json字符串存储在数据库中?
  • 你能告诉我我的js脚本没问题吗??????或者有没有其他方法可以加载这个响应??????我得到了没有任何错误的响应。
  • 我的字符串是有效的 json 字符串现在告诉我为什么它没有在网格中显示记录???????????????

标签: jquery asp.net-mvc c#-4.0 datatables


【解决方案1】:
猜你喜欢
  • 2012-01-09
  • 2016-04-02
  • 1970-01-01
  • 2012-03-18
  • 1970-01-01
  • 2019-12-26
  • 1970-01-01
  • 2017-11-18
  • 2017-01-01
相关资源
最近更新 更多