Iam making get requests with an interval. On page load i want an interval of 2000, but after 1 get request the interval has to be changed to 20000. What is the best approach in this case ?
$(document).ready(function(){
setInterval(function(){
$.ajax({
type: 'GET',
url : "{% url "messages" object.id %}",
success: function(response){
console.log(response);
$("#display").empty();
for (var key in response.messages)
{
var temp = "<div class='container manager' style='color:black'><b>" + response.messages[key].werknemer_naam ;
}
},
error: function(response){
alert('An error occured')
}
});
},2000);
})