【问题标题】:sAjaxSource doesn't get executed in IEsAjaxSource 不会在 IE 中执行
【发布时间】:2010-10-05 04:21:39
【问题描述】:

我在我的 MVC 应用程序中使用 jquery 数据表服务器端。当我在我的控制器方法“FillTable”中设置一个断点时,执行只会在 IE 上第一次到达。如果我返回并重新加载页面并且数据不同,则不会调用该函数。当我尝试 Firefox 时,每次重新加载都会遇到断点,没有任何问题。这是我的代码。

$(document).ready(function() {
    $('.details').dataTable({
        "bServerSide": true,
        "bProcessing": true,
        "sPaginationType": "full_numbers",
        "sAjaxSource": "../PrepareStatements/FillTable",
        "aoColumns": [
            { "sTitle": "#" },
            { "sTitle": "Date" },
            { "sTitle": "Remarks" },
            { "sTitle": "Dr/Cr" },
            { "sTitle": "Amount"}]
    });
});

我的数据表是

<table width="100%" class="details"  id="eDataTable"></table>

但是,如果我更改显示行数,单击分页或执行搜索就可以了。有人可以帮我解决这个问题。

【问题讨论】:

    标签: jquery asp.net-mvc datatables


    【解决方案1】:

    好的,我找到了解决方案。您必须添加 POST,因为 IE 倾向于使用 GET 请求缓存数据结果。我已将以下内容添加到我的函数中,现在可以正常工作了。

    $(document).ready(function() {
        $('.details').dataTable({
            "bServerSide": true,
            "bProcessing": true,
            "sPaginationType": "full_numbers",
            "sAjaxSource": "../PrepareStatements/FillTable",
            "fnServerData": function(sSource, aoData, fnCallback) {
                $.ajax({ "dataType": 'json',
                    "type": "POST",
                    "url": sSource,
                    "data": aoData,
                    "success": fnCallback
                });
            },
            "aoColumns": [
                { "sTitle": "#" },
                { "sTitle": "Date" },
                { "sTitle": "Remarks" },
                { "sTitle": "Dr/Cr" },
                { "sTitle": "Amount"}]
        });
    });
    

    【讨论】:

      猜你喜欢
      • 2019-05-15
      • 2011-11-21
      • 1970-01-01
      • 2013-03-25
      • 2013-12-06
      • 2019-07-31
      • 2011-12-08
      • 1970-01-01
      • 2014-07-23
      相关资源
      最近更新 更多