I'm a newby in web development. Sorry about basic questions.
I have a code block with ajax. It takes data from api, and it has to apply every 10 seconds db updates to page. But it's didn't worked. Why my setTimeout() or setInterval() code getting too much response? I tried both of them.
$(document).ready(function() {
sendRequest();
function sendRequest() {
$.ajax({
url: "http://127.0.0.1:8000/studentsapi",
dataType: "json",
success: function(data) {
$('#first_name').text(data[0].first_name);
$('#last_name').text(data[0].last_name);
$('#age').text(data[0].age);
$('#gender').text(data[0].gender);
},
complete: function(data) {
setTimeout(sendRequest, 10000); //
}
});
}
});
In terminal: