datatables, данные JSON с сервера не могут быть проанализированы

я получаю эту ошибку:

DataTables warning (table id = 'example'): DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error.

в коде ниже. я хочу отправить любой параметр для этого кода для server_processing.php и создать команду SQL с $_GET. этот код показывает этот результат

{"sEcho":0,"iTotalRecords":"1","iTotalDisplayRecords":"112","aaData":[["\u0633\u06cc\u062f \u0645\u062d\u0645\u062f \u0639\u0644\u06cc","\u0645\u062d\u0633\u0646\u06cc","sma_mohseni","2012\/11\/10","50.48.6.52"],["\u0633\u06cc\u062f \u0645\u062d\u0645\u062f \u0639\u0644\u06cc","\u0645\u062d\u0633\u0646\u06cc","sma_mohseni","2012\/11\/10","50.48.6.52"]]}

полный результат — эта ссылка

в проверенном результате json на www.jsonformatter.curiousconcept.com это предупреждает меня, что результат json ДЕЙСТВИТЕЛЬЕН

my server_processing.php is:

<?php

    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
     * Easy set variables
     */

    /* Array of database columns which should be read and sent back to DataTables. Use a space where
     * you want to insert a non-database field (for example a counter or static image)
     */
    $aColumns = array('first_name','last_name','login','date','ip'); 

    /* Indexed column (used for fast and accurate table cardinality) */
    $sIndexColumn = "date";

    /* Database connection information */
    $gaSql['user']       = 'SECURITY ';
    $gaSql['password']   = 'SECURITY ';
    $gaSql['db']         = 'SECURITY ';
    $gaSql['server']     = 'SECURITY ';

    /* 
     * MySQL connection
     */
    $gaSql['link'] =  mysql_pconnect( $gaSql['server'], $gaSql['user'], $gaSql['password']  ) or
        die( 'Could not open connection to server' );

    mysql_select_db( $gaSql['db'], $gaSql['link'] ) or 
        die( 'Could not select database '. $gaSql['db'] );
    mysql_query("set names 'utf8'", $gaSql['link']);            

    /* 
     * Paging
     */

    $sLimit = "";
    if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' )
    {
        $sLimit = "LIMIT ".mysql_real_escape_string( $_GET['iDisplayStart'] ).", ".
            mysql_real_escape_string( $_GET['iDisplayLength'] );
    }

    /*
     * Ordering
     */
    $sOrder = "";
    if ( isset( $_GET['iSortCol_0'] ) )
    {
        $sOrder = "ORDER BY  ";
        for ( $i=0 ; $i<intval( $_GET['iSortingCols'] ) ; $i++ )
        {
            if ( $_GET[ 'bSortable_'.intval($_GET['iSortCol_'.$i]) ] == "true" )
            {
                $sOrder .= "`".$aColumns[ intval( $_GET['iSortCol_'.$i] ) ]."` ".
                    mysql_real_escape_string( $_GET['sSortDir_'.$i] ) .", ";
            }
        }

        $sOrder = substr_replace( $sOrder, "", -2 );
        if ( $sOrder == "ORDER BY" )
        {
            $sOrder = "";
        }
    }

    /* 
     * Filtering
     * NOTE this does not match the built-in DataTables filtering which does it
     * word by word on any field. It's possible to do here, but concerned about efficiency
     * on very large tables, and MySQL's regex functionality is very limited
     */
    $sWhere = "";
    if ( isset($_GET['sSearch']) && $_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 ( isset($_GET['bSearchable_'.$i]) && $_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])."%' ";
        }
    }


    /*
     * SQL queries
     * Get data to display
     */

    $sQuery = "SELECT at_members.member_id , at_members.login , at_members.status , at_statistic.date , at_statistic.time , 
          at_statistic.ip , at_members.first_name , at_members.last_name FROM
          ( I'M EDITED THIS LINES FOR SECURITY )
          at_members.status = '{$_GET['$status']}' {$_GET['con']}
          {$_GET['fDate']}  {$_GET['tDate']} 
          {$_GET['nameDore']} ";

    $rResult = mysql_query( $sQuery, $gaSql['link'] ) or die(mysql_error());

    /* Data set length after filtering */
    $sQuery = "
        SELECT FOUND_ROWS()
    ";
    $rResultFilterTotal = mysql_query( $sQuery, $gaSql['link'] ) or die(mysql_error());
    $aResultFilterTotal = mysql_fetch_array($rResultFilterTotal);
    $iFilteredTotal = $aResultFilterTotal[0];

    /* Total data set length */
    // echo $sQuery.'<br/>';

    $rResultTotal = mysql_query( $sQuery, $gaSql['link'] ) or die(mysql_error());
    $aResultTotal = mysql_fetch_array($rResultTotal);
    $iTotal = $aResultTotal[0];


    /*
     * Output
     */
    $output = array(
        "sEcho" => intval($_GET['sEcho']),
        "iTotalRecords" => $iTotal,
        "iTotalDisplayRecords" => $iFilteredTotal,
        "aaData" => array()
    );

    while ( $aRow = mysql_fetch_array( $rResult ) )
    {
        $row = array();
        for ( $i=0 ; $i<count($aColumns) ; $i++ )
        {
            if ( $aColumns[$i] == "version" )
            {
                /* Special output formatting for 'version' column */
                $row[] = ($aRow[ $aColumns[$i] ]=="0") ? '-' : $aRow[ $aColumns[$i] ];
            }
            else if ( $aColumns[$i] != ' ' )
            {
                /* General output */
                $row[] = $aRow[ $aColumns[$i] ];
            }
        }
        $output['aaData'][] = $row;
    }

    echo json_encode( $output );
?>

HTML:

<div  style="width:100%;">
    <table cellpadding="0" cellspacing="0" border="0" class="display" id="example" >
        <thead>
            <tr>
                <th width="35%"></th>
                <th width="35%"></th>
                <th width="15%"></th>
                <th width="15%"></th>
                <th width="15%"></th>
            </tr>
        </thead>
        <tbody></tbody>
    </table>
</div>

person DolDurma    schedule 09.12.2012    source источник


Ответы (2)


Вы используете недопустимые символы, проверьте результат здесь

Вот этот: \u0645\u062d\u06 33\u0646\u06cc

У вас есть пробел между u06 и 33

Кроме того, у вас может возникнуть проблема с подключаемым модулем проверки jQuery, проверьте эта ссылка для получения дополнительной информации.

person Lotzki    schedule 09.12.2012

Это типичный тип ответа, когда ошибка скрипта произошла на вашем скрипте на стороне сервера. Попробуйте с помощью веб-инспектора Chrome или firebug и вкладки сети проверить, какой результат возвращается.

Скорее всего, будет что-то вроде

PHP error foo on line bar
{your: "json", here: "if", it: "only", was: "a warning", and, "not an error"}
person David Müller    schedule 09.12.2012
comment
jsonformatter.curiousconcept.com предупредит меня, что результат json является ДЕЙСТВИТЕЛЬНЫМ - person DolDurma; 09.12.2012
comment
Результат проверки: Действителен. мой результат json упрощен. полный результат таков: - person DolDurma; 09.12.2012