1 回答

TA貢獻(xiàn)1820條經(jīng)驗 獲得超2個贊
您應(yīng)該 使用 來操作和獲取數(shù)據(jù)。下面的代碼可以清楚地說明如何完成工作: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
});
})();
這將完成獲取和更改顏色(更改顏色是您的部分)。請記住,在內(nèi)部,您應(yīng)該輸入正確的url來獲取數(shù)據(jù)。 將防止錘擊服務(wù)器。下一部分是你的觀點: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')
我認(rèn)為你走在正確的道路上。
添加回答
舉報