これはよくある質問です。Googleが提供できるすべての回答を調査したので、もう一度質問して申し訳ありません。
Firebugは応答を次のように表示します
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
{ "aaData" : [ [ "A",
"0.67",
"0.66",
"0.66",
"0.66",
"0.78",
"1.52",
"0.00",
"0.00",
"-15.38",
"1970-01-01"
],
[ "AA",
"0.11",
"0.12",
"0.12",
"0.14",
"0.12",
"-8.33",
"0.00",
"-14.29",
"16.67",
"2013-04-08"
],
[ "AACC",
"0.03",
"0.04",
"0.04",
"0.04",
"0.10",
"-25.00",
"0.00",
"0.00",
"-60.00",
"2013-03-04"
],
[ "AAN",
"0.50",
"0.50",
"0.50",
"0.50",
"0.49",
"0.00",
"0.00",
"0.00",
"2.04",
"2013-02-04"
],
[ "AAON",
"0.23",
"0.23",
"0.22",
"0.22",
"0.20",
"0.00",
"4.55",
"0.00",
"10.00",
"2013-03-11"
],
[ "AAP",
"0.76",
"0.76",
"0.76",
"0.76",
"0.76",
"0.00",
"0.00",
"0.00",
"0.00",
"2013-02-07"
],
[ "AAPL",
"13.42",
"13.34",
"13.30",
"13.34",
"15.45",
"0.60",
"0.30",
"-0.30",
"-13.66",
"2013-01- 23"
]
],
"iTotalDisplayRecords" : "7",
"iTotalRecords" : "7",
"sEcho" : 1
}
jsonlint.comはjsonが有効であると言っていますが、なぜapacheがDoctypeを応答の前に置いたのですか?これがエラーの原因ですか?
Firebugは、ヘッダーを次のように報告します。
Connection Keep-Alive
Content-Length 798
Content-Type application/json
Date Wed, 23 Jan 2013 09:18:35 GMT
Keep-Alive timeout=5, max=100
Server Apache/2.2.22 (Ubuntu)
X-Powered-By PHP/5.4.6-1ubuntu1.1
DataTablesのserver_processing.phpスクリプトを使用しています
header('Content-Type: application/json');
echo $output;
私のphpの関連部分は次のとおりです。
$(document).ready(function() {
$('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "server_processing.php",
"sPaginationType": "full_numbers"
} );
} );
</script>
</head>
<body>
<div id="dynamic">
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
<thead>
<tr>
<th>Symbol</th>
<th>Current Estimate</th>
<th>7 days ago</th>
<th>30 days ago</th>
<th>60 days ago</th>
<th>90 days ago</th>
<th>% Change Current</th>
<th>% Change 7</th>
<th>% Change 30</th>
<th>% Change 60</th>
<th>Next Earnings Date</th></th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="10" class="dataTables_empty">Loading data from server</td>
</tr>
</tbody>
<tfoot>
<tr>
<th>Symbol</th>
<th>Current Estimate</th>
<th>7 days ago</th>
<th>30 days ago</th>
<th>60 days ago</th>
<th>90 days ago</th>
<th>% Change Current</th>
<th>% Change 7</th>
<th>% Change 30</th>
<th>% Change 60</th>
</tr>
</tfoot>
</table>
私はこれを解決しようとして何時間も失ったので、助けてくれてとても感謝しています。