datatables:jQuery在发布时丢失序列化

时间:2013-07-25 13:33:09

标签: php jquery post datatables

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

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 );
                }
            }
        }
    }
    );
}
);

提醒:(2个复选框在1和2在第二页上检查)

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

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

id=2181&id=2179

1 个答案:

答案 0 :(得分:0)

而不是fnGetNodes,请使用$

示例:

var sData = $('input', oTable.$('tr')).serialize().replace(/%5B%5D/g, '[]');