Beginner here:
I have a simple AJAX component that executes a GET API call every 3 seconds:
<script>
$(document).ready(
function() {
setInterval(function() {
$.get('/value_one', function(res) {
$('#value_one').text(res);
});
$.get('/value_two', function(res) {
$('#value_two').text(res);
});
}, 3000);
}
);
</script>
This works perfectly fine... it calls and gets value from my NodeJS server code every three seconds; As it should. But this is only after the page loads. I would like to fetch the values on page load, and every three seconds after that. How would I do that?