2011-03-15 67 views
0

套牢「從服務器加載數據」與JSON我使用jQuery的數據表一個客戶管理面板上,我測試的一切,它在Chrome,FF,歌劇的工作完美,但是當我嘗試加載它與IE7,8或9只是堅持的「從服務器加載數據」JQuery的數據表中的IE7,IE8,IE9

這裏是我的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" 
     ] 
    ] 
} 

這裏是我的server_processing.php文件(文件生成JSON代碼)

<?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); 
?> 

回答

0

按F-12上的IE8 +和打開腳本控制檯。可能有一個你看不到的錯誤。

而且,沒有必要發表您的服務器端代碼,因爲這是一個客戶端的問題。

0

爲別人有類似的問題我找到了解決。

在data_processing.php文件我改變了單引號雙引號,現在,它在IE7的作品和8

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>"; 
         }