jquerydatatables卡住了";“正在从服务器加载数据”;在IE7、IE8、IE9中使用JSON

jquerydatatables卡住了";“正在从服务器加载数据”;在IE7、IE8、IE9中使用JSON,jquery,json,internet-explorer,datatables,Jquery,Json,Internet Explorer,Datatables,我在客户端管理面板上使用Jquery Datatables,我测试了一切,它在Chrome、FF、Opera中工作得非常好,但当我尝试用IE7、8或9加载它时,它只会坚持“从服务器加载数据” 这是我的JSON,它验证ok { "sEcho":0, "iTotalRecords":"5", "iTotalDisplayRecords":"5", "aaData":[ [ "<a >1783<\/a><a >&

我在客户端管理面板上使用Jquery Datatables,我测试了一切,它在Chrome、FF、Opera中工作得非常好,但当我尝试用IE7、8或9加载它时,它只会坚持“从服务器加载数据”

这是我的JSON,它验证ok

{
   "sEcho":0,
   "iTotalRecords":"5",
   "iTotalDisplayRecords":"5",
   "aaData":[
      [
         "<a >1783<\/a><a ><img ><\/a>",
         "2011-03-12 03:42:06",
         "tommy arnold",
         "30.00",
         "Post",
         "Unpaid",
         "Incomplete"
      ],
      [
         "<a >1797<\/a><a ><img ><\/a>",
         "2011-03-15 17:08:09",
         "tommy arnold",
         "130.00",
         "Post",
         "Unpaid",
         "Incomplete"
      ],
      [
         "<a >1798<\/a><a ><img ><\/a>",
         "2011-03-15 17:12:04",
         "tommy arnold",
         "137.00",
         "Post",
         "Unpaid",
         "Incomplete"
      ],
      [
         "<a >1799<\/a><a ><img ><\/a>",
         "2011-03-15 17:12:34",
         "tommy arnold",
         "58.00",
         "Post",
         "Unpaid",
         "Incomplete"
      ],
      [
         "<a >1800<\/a><a ><img ><\/a>",
         "2011-03-15 17:13:00",
         "tommy arnold",
         "91.00",
         "Post",
         "Unpaid",
         "Incomplete"
      ]
   ]
}
{
“sEcho”:0,
“iTotalRecords”:“5”,
“iTotalDisplayRecords”:“5”,
“aaData”:[
[
"';
}
否则如果($aColumns[$i]!='')
{
/*一般输出*/
$row[]=$aRow[$aColumns[$i]];
}
}
$output['aaData'][]=$row;
}
echo json_编码($output);
?>

在ie8+上按F-12并打开脚本控制台。可能存在您看不到的错误


此外,无需发布服务器端代码,因为这是一个客户端问题。

对于其他有类似问题的人,我找到了一个解决方案。

在data_processing.php文件中,我将单引号改为双引号,现在它可以在IE7和IE8中使用

<?php
include"../inc/config.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( 'ID', 'date', 'address_name', 'total', 'paymentOption', 'payment_status', 'orderStatus');

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

    /* DB table to use */
    $sTable = "orders";

    /* Database connection information */
    $gaSql['user']       = $dbuser;
    $gaSql['password']   = $dbpass;
    $gaSql['db']         = $dbname;
    $gaSql['server']     = $dbhost;



    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
     * If you just want to use the basic configuration for DataTables with PHP server-side, there is
     * no need to edit below this line
     */

    /* 
     * 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'] );


    /* 
     * 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 SQL_CALC_FOUND_ROWS ".str_replace(" , ", " ", implode(", ", $aColumns))."
        FROM   $sTable
        $sWhere
        $sOrder
        $sLimit
    ";
    $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 */
    $sQuery = "
        SELECT COUNT(".$sIndexColumn.")
        FROM   $sTable
    ";
    $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']),
        "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] ];
            }
             elseif ( $aColumns[$i] === "ID" )
                        {
                                /* Special output formatting for 'name' column */
  $row[] = '<a href="invoice.php?ORDERID='. $aRow[ $aColumns[$i] ]. '" target="_blank" title="'. 'View Invoice: '. $aRow[ $aColumns[$i] ]. '">'. $aRow[ $aColumns[$i] ]. '</a><a href="invoice.php?action=delete&ORDERID='. $aRow[ $aColumns[$i] ]. '" onClick="return confirm(\'Are you sure you want to delete?\')"><img src="../images/icons/trash-can-delete.png" width="16" height="16"></a>';
                        }

            else if ( $aColumns[$i] != ' ' )
            {
                /* General output */
                $row[] = $aRow[ $aColumns[$i] ];
            }

        }
        $output['aaData'][] = $row;
    }

    echo json_encode( $output );
?>
elseif($aColumns[$i]=“ID”)
{
$row[]=“”;
}
这可能会有帮助……而且你还可以学到一些东西

elseif ( $aColumns[$i] === "ID" )
                        {

  $row[] = "<a href=\"invoice.php?ORDERID=".$aRow[ $aColumns[$i] ]."\" target=\"_blank\" title=\"View Invoice: ".$aRow[ $aColumns[$i] ]."\">".$aRow[ $aColumns[$i] ]."</a><a href=\"invoice.php?action=delete&ORDERID=".$aRow[ $aColumns[$i] ]."\"onClick=\"return confirm('Are you sure you want to delete?')\"><img border=\"0\" src=\"../images/icons/trash-can-delete.png\" width=\"16\" height=\"16\"></a>";
                        }