javascript에서 라이브 데이터를로드하고 새로 고치려고합니다. 그러나 나는 그것을 보여줄 수 없다.Javascript Ajax Get
Heres는 내 코드 :
<!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>"}
. 이 코드를 실행하려면 서버에 특별한 설치가 필요합니까?
로? –
방화 광구를 사용하여 실제로 데이터를 제대로 보내고 받고 있는지 확인하십시오. – Ryoku
'
'로 호출 해 보았습니다.하지만 작동하지 않았습니다. –