2016-06-09 93 views
0

我使用jquery 1.7.1,因爲這是我的舊項目,所以我無法更改它。我面臨問題在設置JSON數據返回通過我的控制器到javascript的javascript調用到數據表。 以下是我的Ajax調用如何將json數據設置爲jquery 1.7數據表

$.ajax({ 
    type : "post", 
    url : "myController", 
    dataType : 'json', 
    data : 'operation=getUploaded&filename=' + filename, 
    success : function(data) { 

     console.log("<<<<<<<<<<<data<<<<<<<<<<<", data.Data[0]); 
     $('#example').dataTable({ 
      "aoData": data.Data[0], 
      "aoColumns": [ 
       { "mDataProp": "id" }, 
       { "mDataProp": "point" }, 
       { "mDataProp": "floor" }, 
       { "mDataProp": "custAccNo" }, 
       { "mDataProp": "data" } 
     ] 

     }); 
    } 
}); 

這裏是我的json返回:

{ 
    "Data": [{ 
     "id": 4534534, 
     "point": "45", 
     "floor": "345", 
     "custAccNo": "000000001", 
     "data": "ABC", 
     "fileName": "23rbc.rti", 
     "grid": "001" 
    }] 
} 

這是我在我的JSP表:

<div class="container"> 
    <table cellpadding="0" cellspacing="0" border="0" class="dataTable" id="example"> 
     <thead> 
      <tr> 
       <th>id</th> 
       <th>point</th> 
       <th>floor</th> 
       <th>custAccNo</th> 
       <th>data</th> 
      </tr> 
     </thead> 
    </table> 
</div> 

任何建議?

+1

你得到一個錯誤的第一個對象?請發佈您面臨的確切問題。 –

+0

顯示空數據表,無錯誤。 @Hector –

+0

正確的設置是'aaData',而不是'aoData' ... – davidkonrad

回答

0

你的陣列是data.Datadata.Data[0]這是陣列

+0

我修改了。但仍然沒有顯示 –

相關問題