ライブデータをロードして更新するためにJavaScriptを取得しようとしています。しかし、データを表示することはできません。
これが私のコードです:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
</head>
<script type="text/javascript">
function updateStats() {
$.ajax({
type: 'GET',
url: "http://localhost/data.php",
dataType: 'json',
success: function(data) {
$('#sysstats').html(data.sysstats);
$('#aststats').html(data.aststats);
scheduleStatsUpdate();
},
error: updateFailed
});
}
function scheduleStatsUpdate() {
stats_timer = setTimeout('updateStats();',6000);
}
</script>
<body>
<div id="aststats" class="infobox ui-widget-content ui-corner-all">
</div>
<div id="sysstats" class="infobox ui-widget-content ui-corner-all">
</div>
</body>
Data.phpファイルは次の内容を返します。
{"sysstats":"<h3 class=\"ui-widget-header ui-state-default ui-corner-all\">System Statistics<\/h3><h4>Processor<\/h4><div class=\"databox\" style=\"width:200px;\">\n <div class=\"dataname\">Load Average<\/div>\n <div class=\"datavalue\"><a href=\"#\" title=\"Load Average: 0.01\">0.01<\/a><\/div>\n<\/div>\n<div class=\"databox graphbox\" style=\"width:200px;\" title=\"CPU: 0.00 \/ 100 (0%)\">\n <div class=\"bargraph graphok\" style=\"width:0px;\"><\/div>\n <div class=\"dataname\">CPU<\/div>\n <div class=\"datavalue\">0%<\/div>\n<\/div>\n<h4>Memory<\/h4><div class=\"databox graphbox\" style=\"width:200px;\" title=\"App Memory: 527.67MB \/ 2010.453125MB (26%)\">\n <div class=\"bargraph graphok\" style=\"width:52px;\"><\/div>\n <div class=\"dataname\">App Memory<\/div>\n <div class=\"datavalue\">26%<\/div>\n<\/div>\n<div class=\"databox graphbox\" style=\"width:200px;\" title=\"Swap: 0.00MB \/ 760.8828125MB (0%)\">\n <div class=\"bargraph graphok\" style=\"width:0px;\"><\/div>\n <div class=\"dataname\">Swap<\/div>\n <div class=\"datavalue\">0%<\/div>\n<\/div>\n<h4>Disks<\/h4><div class=\"databox graphbox\" style=\"width:200px;\" title=\"\/: 2.53GB \/ 30.18GB (8%)\">\n <div class=\"bargraph graphok\" style=\"width:16px;\"><\/div>\n <div class=\"dataname\">\/<\/div>\n <div class=\"datavalue\">8%<\/div>\n<\/div>\n<div class=\"databox graphbox\" style=\"width:200px;\" title=\"\/boot: 0.01GB \/ 0.10GB (10%)\">\n <div class=\"bargraph graphok\" style=\"width:20px;\"><\/div>\n <div class=\"dataname\">\/boot<\/div>\n <div class=\"datavalue\">10%<\/div>\n<\/div>\n<div class=\"databox graphbox\" style=\"width:200px;\" title=\"\/dev\/shm: 0.00GB \/ 0.98GB (0%)\">\n <div class=\"bargraph graphok\" style=\"width:0px;\"><\/div>\n <div class=\"dataname\">\/dev\/shm<\/div>\n <div class=\"datavalue\">0%<\/div>\n<\/div>\n<h4>Networks<\/h4><div class=\"databox\" style=\"width:200px;\">\n <div class=\"dataname\">eth0 receive<\/div>\n <div class=\"datavalue\"><a href=\"#\" title=\"eth0 receive: 0.00 KB\/s\">0.00 KB\/s<\/a><\/div>\n<\/div>\n<div class=\"databox\" style=\"width:200px;\">\n <div class=\"dataname\">eth0 transmit<\/div>\n <div class=\"datavalue\"><a href=\"#\" title=\"eth0 transmit: 0.00 KB\/s\">0.00 KB\/s<\/a><\/div>\n<\/div>\n","aststats":"<h3 class=\"ui-widget-header ui-state-default ui-corner-all\">FreePBX Statistics<\/h3><div class=\"databox graphbox\" style=\"width:400px;\" title=\"Total active calls: 0 \/ 18 (0%)\">\n <div class=\"bargraph graphok\" style=\"width:0px;\"><\/div>\n <div class=\"dataname\">Total active calls<\/div>\n <div class=\"datavalue\">0<\/div>\n<\/div>\n<div class=\"databox graphbox\" style=\"width:400px;\" title=\"Internal calls: 0 \/ 18 (0%)\">\n <div class=\"bargraph graphok\" style=\"width:0px;\"><\/div>\n <div class=\"dataname\">Internal calls<\/div>\n <div class=\"datavalue\">0<\/div>\n<\/div>\n<div class=\"databox graphbox\" style=\"width:400px;\" title=\"External calls: 0 \/ 18 (0%)\">\n <div class=\"bargraph graphok\" style=\"width:0px;\"><\/div>\n <div class=\"dataname\">External calls<\/div>\n <div class=\"datavalue\">0<\/div>\n<\/div>\n<div class=\"databox graphbox\" style=\"width:400px;\" title=\"Total active channels: 0 \/ 36 (0%)\">\n <div class=\"bargraph graphok\" style=\"width:0px;\"><\/div>\n <div class=\"dataname\">Total active channels<\/div>\n <div class=\"datavalue\">0<\/div>\n<\/div>\n<h4>FreePBX Connections<\/h4>"}
データを表示することすらできません。このコードを実行するには、サーバーに特別なインストールが必要ですか?