So i simply use this updateData function to get values from my php file it works after the first interval, but I would like to get first data after the page loads so I've tried doing var
var dataset=[];
updateData();
Before the intervals starts but dataset is still not updated immidiately I get empty array []
function updateData(){
$.ajax({
type: 'POST',
url: 'parser.php',
dataType: 'json',
cache: false,
success: function(result) {
dataset = result;
},
});
}
<?php
$datasetJSON = array();
for($i=0;$i<7;$i++){
$datasetJSON[] = rand(1,1000);
}
echo json_encode($datasetJSON);
?>