Hi, I have a huge problem that has been listening to me for a long time, in most cases I could have avoided it, but now there is no other way. Below is a function that, when executed, sends an email request for each checked field. I need him to wait for $ .each to complete to refresh the page. I ran tests with location.reload in the callback of each and for each of them. Of the 10 selected fields, only 7-8 are processed with a reload in the $ .each callback and 3-4 if they move after $ .each (still inside .click). I need him to somehow wait for $ .each to finish and then refresh the page. Is there any way to do this?
$('button.moveToTable').click(function(event){
$("input:checked").each(function(){
$.post('/table/move-to-table',
{orderID: $(this).val(),
tableID: $('#moveToTableID').val()
},
function(data){
location.reload();
});
});
});