0

有人可以帮我吗?在提醒 sData 时,它包含我需要的所有值,但在 POST 时,它仅包含数据表中当前页面的数据。

var oTable;
$(document).ready
(
function()
{
    $('#form0').submit
    (
        function()
        {
            var sData = $('input', oTable.fnGetNodes()).serialize().replace(/%5B%5D/g, '[]');
            alert( "The following data would have been submitted to the server: \n\n"+sData );
            $( {
            "type": "POST",
            "dataType": "html",
            "url": $("#form0").attr('action'),
            "data": sData,
            "success": fnCallback
            } );
            return false;
        }
    );
    var oTable = $('#gridtable0').dataTable(    
    {
        "sDom": 'T<"clear">lfrtip',
        "bSortClasses": false,
        "sPaginationType": "full_numbers",
        "fnDrawCallback": function ( oSettings )
        {
            /* Need to redo the counters if filtered or sorted */
            if ( oSettings.bSorted || oSettings.bFiltered )
            {
                for ( var i=0, iLen=oSettings.aiDisplay.length ; i<iLen ; i++ )
                {
                    $('td:eq(0)', oSettings.aoData[ oSettings.aiDisplay[i] ].nTr ).html( i+1 );
                }
            }
        }
    }
    );
}
);

警报:(在 1 上选中了 2 个复选框,在第二页上选中了两个)

id=2205&id=2204&id=2181&id=2179

POST:(在当前页面上选中了 2 个复选框)

id=2181&id=2179
4

1 回答 1

0

而不是fnGetNodes,使用$

例子:

var sData = $('input', oTable.$('tr')).serialize().replace(/%5B%5D/g, '[]');
于 2014-01-24T21:10:44.987 回答