1 回答

TA貢獻1820條經驗 獲得超3個贊
您應該 使用 來操作和獲取數據。下面的代碼可以清楚地說明如何完成工作:JQuery/AjaxDOM
(function chColor() {
$.ajax({
type: "GET",
url: "url to your view",
success: function (data) {
// here you can get data from backend and do changes like
// changing color by the data coming from your view.
}
}).then(function() { // on completion, restart
setTimeout(chColor, 30000); // function refers to itself
});
})();
這將完成獲取和更改顏色(更改顏色是您的部分)。請記住,在內部,您應該輸入正確的url來獲取數據。 將防止錘擊服務器。下一部分是你的觀點:urlsetTimeoutnetstat
def netstat(request):
results = []
data_json = {}
for line in snmpvalues:
if line == '1':
data_json['flag']="1"
results.append(data_json)
else:
data_json['flag']="0"
results.append(data_json)
final = json.dumps(results)
return HttpResponse(final, 'application/json')
我認為你走在正確的道路上。
添加回答
舉報