0

我在我的 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>

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

4

1 回答 1

2

好的,我找到了解决方案。您必须添加 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"}]
    });
});
于 2010-10-05T04:54:11.840 回答