我正在開發代碼以從遠程Ajax獲取數據,但無法顯示所需的數據。標籤顯示但數據不顯示
但是標籤的名稱已正確顯示。
從遠程,在PHP我這樣的:
for ($i = $start; $i <= $end; $i = $i + 86400) {
$SQDate = date('Y-m-d', $i);
$PMS_ci = $this->getPMS_ci_status($SQDate);
$PMS_co = $this->getPMS_co_status($SQDate);
if($PMS_ci["sum"] == "")
$PMS_ci["sum"] = "0";
if($PMS_co["sum"] == "")
$PMS_co["sum"] = "0";
$arrival[] = $PMS_ci["sum"];
$departure[]= $PMS_co["sum"];
}
$data[] = array("name" => "Arrival", "data" => join($arrival,","));
$data[] = array("name" => "Departure", "data" => join($departure,","));
return JSON_encode($data);
端JavaScript:
retour = JSON.parse(data.message);
Highcharts.chart('container', {
chart: {
type: 'spline'
},
.../...
,
series: [{name: retour[0].name ,data: retour[0].data},
{name: retour[1].name, data: retour[1].data}],
navigation: {
.../...
數據的內容返回此:
[
{
"name":"Arrival",
"data":"[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,0,0,0,0,0,0,0,0,0,0,0]"
},
{
"name":"Departure",
"data":"[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,0,0,0,0,0,0,0,0,0,0]"
}
]
在所有情況下,所需數據不顯示,但名稱顯示正確。
我不知道爲什麼,我在這裏讀了一些線程,但沒有成功。應該做些什麼來確保數據與標籤一起顯示?
你能爲你提供HTML你可以重寫你的代碼是怎樣的?什麼是'data.message'? – t3mplar