Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/74.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.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
Jquery 通过fnServerData在datatables插件中搜索问题_Jquery_Datatable - Fatal编程技术网

Jquery 通过fnServerData在datatables插件中搜索问题

Jquery 通过fnServerData在datatables插件中搜索问题,jquery,datatable,Jquery,Datatable,我想将数据传递到要搜索的服务器页面,如果我提供了多个参数,我会在服务器文件上回显/打印查询,而这些文件不会连接where。它只在where中显示最后提供的参数。这是我的代码 "fnServerData": function ( sSource, aoData, fnCallback ) { /* Add some extra data to the sender */ aoData.p

我想将数据传递到要搜索的服务器页面,如果我提供了多个参数,我会在服务器文件上回显/打印查询,而这些文件不会连接where。它只在where中显示最后提供的参数。这是我的代码

"fnServerData": function ( sSource, aoData, fnCallback ) {
                            /* Add some extra data to the sender */
                            aoData.push( 
                             { "name": "type", "value": $('#type_dummy').val() },
                             { "name": "category_id", "value": $('#category_id').val() },
                             { "name": "region_id", "value": $('#region_id').val() }

                            );

                            $.getJSON( sSource, aoData, function (json) { 
                                /* Do whatever additional processing you want on the callback, then tell DataTables */
                                fnCallback(json)

                } );
            }
在服务器端处理文件时,我有这个

$sWhere = "";
if ( $_GET['sSearch'] != "" )
{
    $sWhere = "WHERE (";
    for ( $i=0 ; $i<count($aColumns) ; $i++ )
    {
        $sWhere .= $aColumns[$i]." LIKE '%".mysql_real_escape_string( $_GET['sSearch'] )."%' OR ";
    }
    $sWhere = substr_replace( $sWhere, "", -3 );
    $sWhere .= ')';
}

/* Individual column filtering */
for ( $i=0 ; $i<count($aColumns) ; $i++ )
{
    if ( $_GET['bSearchable_'.$i] == "true" && $_GET['sSearch_'.$i] != '' )
    {
        if ( $sWhere == "" )
        {
            $sWhere = "WHERE ";
        }
        else
        {
            $sWhere .= " AND ";
        }
        $sWhere .= $aColumns[$i]." LIKE '%".mysql_real_escape_string($_GET['sSearch_'.$i])."%' ";
    }
}

 if(isset($_GET['type'])  && $_GET['type'] != '' ){
$sWhere = "WHERE rent.type = '$_GET[type]' ";
 }
  if(isset($_GET['category_id'])  && $_GET['category_id'] != '' ){
$sWhere = "WHERE rent.category_id = '$_GET[category_id]' ";
 }
查询的where是这样的(其他查询可以)


如果此问题仍处于活动状态:

三个步骤/问题:

我刚刚解决了同样的问题。在使用带有三个参数的“fnServerData()时,我只使用了带有一个参数的fnServerParams()——aoData。我在aoData.push中的三个附加参数与您的类似

其次,我使用Firebug来确保在URL中为$\u GET发送附加参数,以便正确获取。清除浏览器中的历史记录非常重要,以确保这不会干扰您的更改

最后,我有一个全面的类函数,它可以处理服务器PHP位,因此很难(但并非不可能)将其用作服务器脚本的解决方案。如果这个问题仍然有效且未解决,我将提供对PHP脚本的更详细分析

/view_match_lead_server.php?type=1&category_id=1
WHERE category_id=1