My recursive Ajax call is functioning correctly (the PHP script is doing its job, recursion is working, everything is fine) EXCEPT that in between the ajax calls, I am trying to update an input text value to show the progress, but it only updates once the entire loop is done.
I'm wondering why this line of code isn't executing:
$('#start_'+code_regional).val(msg);
Any insights on why this might be happening?
function addLeads(code_regional, phone_numbers_start)
{
var databases = [];
var file = document.getElementById('file_'+code_regional).files[0];
var formData = new FormData();
formData.append('selectedDatabases', JSON.stringify(databases));
formData.append('code_regional', code_regional);
formData.append('phone_numbers_start', phone_numbers_start);
formData.append('phone_numbers_end', $('#end_'+code_regional).val());
formData.append('filePath', file);
$.ajax({
type: 'POST',
url: 'execute.php',
data: formData,
processData: false,
contentType: false,
success: function(msg){
$('#start_'+code_regional).val(msg);
if(msg < $('#end_'+code_regional).val())
{
addLeads(code_regional, msg);
}
else
{
$('#start_'+code_regional).val($('#end_'+code_regional).val());
}
}
});
}