php - how to fetch database value in ajax each 5 seconds -


i created function sum database records using mvc. need fetch values each 5 seconds. values updated time couldn't fetch latest value (the updated value), value when page loaded. finish: need use external file sum.

    function totalcosern(){          $getvalores = $this->db->select("select cosern planilha");          $acc = array_shift($getvalores);         foreach ($getvalores $val) {             foreach ($val $key => $val) {                 $acc[$key] += $val;             }         }         return $acc;         print_r($acc)//print sum      } 

put ajax call in function , use setinterval execute function every 5 seconds , append response in content div.

(function polling() {   $.post('total.php', function(data) {   $('#content').append(data);   settimeout(polling, 1000);   }); })(); 

Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -