DataTables搜索框导致无效的JSON响应'

时间:2014-07-10 09:39:32

标签: javascript php json oracle jquery-datatables

我在我正在建设的网站上使用DataTables。

使用以下方式初始化DataTable:

    <script type="text/javascript" charset="utf-8">
        $.fn.dataTable.ext.legacy.ajax = true;
        $(document).ready(function() {
            $('#example').dataTable( {
                "processing": true,
                "serverSide": true,
                "ajax": "server_processing.php"
            } );
        } );
    </script>

显示DataTable并单击列标题以对排序等进行排序以及分页工作正常但是在搜索框中放置某些内容会导致浏览器显示“无效的JSON响应”并清除搜索框使其成为可能好的。

以下是“开发人员工具”中“网络”标签中显示的错误消息:

  


注意:未定义的索引:bSearchable_3 in    /var/www/portal/server_processing.php 138 行上<   
警告:oci_bind_by_name():ORA-01036:非法    /var/www/portal/server_processing.php 中的变量名称/编号   在线 242

警告:oci_bind_by_name():   ORA-01036:非法变量名称/号码   第 243 /var/www/portal/server_processing.php   
警告:oci_bind_by_name():ORA-01036:非法    /var/www/portal/server_processing.php 中的变量名称/编号   在线 242

警告:oci_bind_by_name():   ORA-01036:非法变量名称/号码   第 243 /var/www/portal/server_processing.php   
警告:oci_bind_by_name():ORA-01036:非法    /var/www/portal/server_processing.php 中的变量名称/编号   在线 242

警告:oci_bind_by_name():   ORA-01036:非法变量名称/号码    /var/www/portal/server_processing.php 243

我检查了server_processing.php,但没有看到任何会导致这种情况的错误。以下是相关行:

if ( $_GET['sSearch'] != "" )
{
    //Set a default where clause in order for the where clause not to fail
    //in cases where there are no searchable cols at all.
    $sWhere = "WHERE (";
    for ( $i=0 ; $i<count($aColumns)+1 ; $i++ )
    {
        //If current col has a search param
        if ( $_GET['bSearchable_'.$i] == "true" )
        {
            //Add the search to the where clause
            $sWhere .= $aColumns[$i]." LIKE '%".$_GET['sSearch']."%' OR ";
            $nWhereGenearalCount += 1;
        }
    }
    $sWhere = substr_replace( $sWhere, "", -3 );
    $sWhere .= ')';
}

/* Individual column filtering */
$sWhereSpecificArray = array();
$sWhereSpecificArrayCount = 0;
for ( $i=0 ; $i<count($aColumns) ; $i++ )
{
    if ( $_GET['bSearchable_'.$i] == "true" && $_GET['sSearch_'.$i] != '' )
    {
        //If there was no where clause
        if ( $sWhere == "" )
        {
            $sWhere = "WHERE ";
        }
        else
        {
            $sWhere .= " AND ";
        }

            //Add the clause of the specific col to the where clause
            $sWhere .= $aColumns[$i]." LIKE '%' || :whereSpecificParam".$sWhereSpecificArrayCount." || '%' ";

            //Inc sWhereSpecificArrayCount. It is needed for the bind var.
            //We could just do count($sWhereSpecificArray) - but that would be less efficient.
            $sWhereSpecificArrayCount++;

            //Add current search param to the array for later use (binding).
            $sWhereSpecificArray[] =  $_GET['sSearch_'.$i];

        }
    }

    //If there is still no where clause - set a general - always true where clause
    if ( $sWhere == "" )
    {
        $sWhere = "WHERE 1=1";
    }

有人可以看到为什么在搜索框中放置某些内容会导致这些问题,因为我没有在代码中看到问题?

0 个答案:

没有答案