Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3273428
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:55:51+00:00 2026-05-17T18:55:51+00:00

Hi I have a huge problem that’s been bugging me for quite a while,

  • 0

Hi I have a huge problem that’s been bugging me for quite a while, most of the times I have been able to avoid it but now there is no other way. Below is a function that when executed sends a post request for every checked boxes. I need it to wait until the $.each has finished to refresh the page. I have performed tests with location.reload in the callback of each and outside of each. Out of 10 selected boxes only 7-8 are processed with the reload in the callback of $.each and 3-4 if moved after $.each (still inside the .click). I need it to wait, somehow, for $.each to finish and then refresh the page. Is there a way to do that?

$('button.moveToTable').click(function(event){
            $("input:checked").each(function(){
                $.post('/table/move-to-table',
                {orderID: $(this).val(),
                    tableID: $('#moveToTableID').val()
                },
                function(data){
                    location.reload();
                });
            });
            //location.reload();
        });
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T18:55:52+00:00Added an answer on May 17, 2026 at 6:55 pm

    One simple way is to store the number of elements in a global scope and subtract them. When the last element finishes the request it will reload. Note that if some request return an error this will fail, you have to handle the error event as well subtracting the window.Remaining. Two or more clicks might corrupt this method as well.

    window.Remaining = 0;
    $('button.moveToTable').click(function(event){
        window.Remaining = $("input:checked").length;
        $("input:checked").each(function(){
            $.post('/table/move-to-table',
            {orderID: $(this).val(),
                tableID: $('#moveToTableID').val()
            },
            function(data){
                --window.Remaining;
                if (window.Remaining == 0)
                    window.location.reload();
            });
        });
        //location.reload();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry for maybe dumb question, but i have HUGE problem with one case when
I am editing a huge number of legacy ASP pages that have been converted
I have a huge web app that is having issues with memory leak in
I have a huge file that I must parse line by line. Speed is
I have a problem that is surely familiar to many: I'm making a call
I have a huge problem with this method im trying to make. I have
I have a huge problem with the REPLACE SQL function in Microsoft SQL Server
I have this huge problem with memory management. The problem : I've got a
I have almost solved a huge problem with png files and transparency in IE
I've a huge problem. I'm having a div named #box that loads external content

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.