I need to make ajax calls in a cycle making new call after the previous is finished.
for (var year = 2000; year <= 2017; year++)
{
$.ajax(
{
url: 'calendar.php?year=' + year,
beforeSend: function()
{
console.log('Loading year: ' + year);
},
success: function(result)
{
$('#events').append(result);
}
});
}
But when I check the console all calls are made at the same time.