Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用搜索功能时,jquerydatatables(旧版)似乎向服务器发送了太多的ajax调用_Jquery_Ajax_Datatables - Fatal编程技术网

使用搜索功能时,jquerydatatables(旧版)似乎向服务器发送了太多的ajax调用

使用搜索功能时,jquerydatatables(旧版)似乎向服务器发送了太多的ajax调用,jquery,ajax,datatables,Jquery,Ajax,Datatables,因此,我们使用的数据表(1.9.4,旧版)如下所示: $('table.classname').dataTable({ "bProcessing": true, "bServerSide": true, "sAjaxSource": "/something.php", "fnServerParams": function ( aoData ) { aoData.push( { "name": "par

因此,我们使用的数据表(1.9.4,旧版)如下所示:

    $('table.classname').dataTable({
        "bProcessing": true,
        "bServerSide": true,
        "sAjaxSource": "/something.php",
        "fnServerParams": function ( aoData ) {
            aoData.push( { "name": "param", "value": <?=$_GET['id']?> });
        }
    });
$('table.classname').dataTable({
“bProcessing”:正确,
“bServerSide”:正确,
“sAjaxSource”:“/something.php”,
“fnServerParams”:函数(aoData){
推送({“name”:“param”,“value”:});
}
});
然后,有人使用搜索输入,可能会键入类似“hello world”的内容——当用户键入时,dataTables插件会对something.php进行11次单独的ajax调用,例如 “h” 然后 “他” 然后 “hel” ... 等等

我看不到文档中提到的任何方法,比如在客户端发送请求之前,如何在进行服务器调用之前添加延迟,例如,1秒或1.5秒,不键入

然而,我确实看到这里提到:例如,通过发送每个“下一个”分页操作的请求,可能会导致服务器过载,但正如我所发现的,这种担心似乎更令人担忧


还有谁能解决这个问题吗?(是的,我们确实需要优化服务器端API调用,但是最小化来自dataTables的API调用也会非常有帮助。)

您可以利用
fnServerData
()并取消Ajax调用。有很多不同的库可以对某些内容进行去Bouncing,但我倾向于在或中使用该库。

Perfect,您确实为我节省了大量时间——谢谢,我以前从未听说过去Bouncing,而且我还没有找到文档中完全正确的部分来覆盖它。:-)