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

  • SEARCH
  • Home
  • 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 8242577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:12:58+00:00 2026-06-07T21:12:58+00:00

I have the following code, which is supposed to open a modal dialog with

  • 0

I have the following code, which is supposed to open a modal dialog with a progress bar. The progress bar should advance as ajax calls go one in the background. The problem is, the dialog box is not opening until after the for loop is complete, all the ajax calls are done. I think I am supposed to the .promose() function somehow, but I am not sure how to implement it in this case. Can someone help me?

jQuery('#div_id')
    .button()
    .click(function(){
        var grid = jQuery('#grid_id');
        var sel_ar = grid.jqGrid('getGridParam', 'selarrrow');
        var last_id = 0;

        //open modal progress bar to display the progress of the emails
        jQuery('#dialog').html('<div id="progressbar"></div>');
        jQuery('#dialog').dialog({
            modal: true
        });
        jQuery('#dialog').dialog('open');

        for (var i = 0;i < sel_ar.length;i++){
            var orderid = jQuery('#grid_id').jqGrid('getCell', sel_ar[i], 'order_id');

            if (last_id != orderid){
                jQuery.ajax({
                    async: false,
                    url: "/scripts/ajax/script.php",
                    type: "post",
                    data: "orderid="+orderid,
                    success: function(data){
                        if (data != "true"){
                            alert(data);
                        }
                        jQuery('#progressbar').progressbar({ value: Math.round((i/sel_ar.length)*100) });
                    }
                });
            }
            last_id = orderid;
            pausecomp(1000);
        }
        //jQuery('#dialog').dialog('close');
        jQuery("#keys_list").trigger("reloadGrid");
        jQuery("#purchased_users").trigger("reloadGrid");
    });

The pausecomp() is a function that just pauses for a certain number of milliseconds. I was trying to put this in to make sure it was taking some time to complete the for loop, so I could see the progress bar ticking… Unfortunately it just extended the time i had to wait to see the progress bar pop up after everything was all done.

I have made a fiddle that illustrates the problem. Notice how it waits until the end of the for loop to update the progress bar. http://jsfiddle.net/YxGqG/5/

Thanks!

  • 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-06-07T21:12:59+00:00Added an answer on June 7, 2026 at 9:12 pm

    You need to remove the async false. it’s going to lock up your browser and if the dialog hasn’t been displayed, it won’t display until after the ajax request. Additionally, the async:false is going to cause the updates to the progress bar to be clunky.

    Delete the line “async:false” you will then need to fix the state issue with updates to the progress bar, after you fix that issue this will work how you want it to.

    Also, that lag you are seeing in the updates to the progress bar is due to using async:false. The UI thread of the browser is in a race condition with your javascript, and when you hit the ajax call with async false, everything stops, including the “in-process” ui update to change the display of the progress bar. That’s a high level.

    UPDATE
    here you go: http://jsfiddle.net/xe8wF/2/ (fixed the bug that caused it to stop at 99%)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code, which is supposed to try to parse a given
I have the following code which is supposed to be removing a particular email
I have the following code, which is supposed to create a form on the
i have the following code, which is supposed to give specific functionality but it
I have the following code which does what it's supposed to do: objSQLCommand =
I have the following code which supposed to display a TreeView (the original code
I have the following code which is supposed to increment a field value by
I have the following functions. One is supposed to receive an id, which is
I have the following code, which is supposed to add a shared_ptr instance to
I have the following code which is supposed to stop anything from happening when

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.