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 7085937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:29:12+00:00 2026-05-28T07:29:12+00:00

I have a friend that wants to incrementally move data from one db to

  • 0

I have a friend that wants to incrementally move data from one db to another and display errors while doing that. I felt I could help by writing a quick script for him and I completed it in about an hour and works fine in Opera and Firefox (testing with dragonfly and firebug). When he tried it in Chrome, the browser locked up until the for or while loop was done and it took considerable longer to complete. Here is my code (without the error catch part that reads the json):

jQuery.noConflict();
jQuery('#myForm').submit(function(form) {
    form.preventDefault();
    var increment = (jQuery("input#increment").val())*1;
    var total = jQuery("input#total").val();
    var progress = 0;
    jQuery("#progressbar").progressbar({value: 0});
    //for (progress = 0; progress < total; progress = progress + increment)
    while (progress < total)
    {
        jQuery.ajax({
            url: 'progressBarAjax.php',
            type: "POST",
            async: false,
            dataType: "json",
            data: {
                ajax: 'goAjax',
                total: total,
                increment: increment,
                progress: progress
            },
            success: function(data){
                jQuery("#progressbar").progressbar({value: data.value});
            }
        });
        progress = progress + increment;
    }
});

also, for further reference, the code for catching errors has been stripped during debugging and data.value = floor(($progress / $total) * 100). You can also see where I have tried both for and while and both work fine in Opera and Firefox but not Chrome.

Knowing why this behavior happens would be nice to know for future projects but also I would like to write it properly as well. The objectives are to take 200k inserts/updates and break them up in to smaller chunks, run the queries synchronously, and update a progress bar in the process.

  • 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-28T07:29:13+00:00Added an answer on May 28, 2026 at 7:29 am

    Well, you’re using async:false so the browser will lock while the request is made. That while can also get into an infinite loop if increment is 0..

    I would think you actually want query the server, and if the server comes back and says it’s not done yet in it’s json response, then query it again, until it says it is. Something like:

    var increment, total, progress;
    
    function getProgress(){
        jQuery.ajax({
            url: 'progressBarAjax.php',
            type: "POST",
            async: true,
            dataType: "json",
            data: {
                ajax: 'goAjax',
                total: total,           // Obviously, I don't know what these
                increment: increment,   // do on your server, so I've kept
                progress: progress      // them here.
            },
            success: function(data){
                // Assuming data.value is the progress from 1-100?
                // otherwise, figure out the progress from the data response
                progress = data.value;
                jQuery("#progressbar").progressbar({value: progress});
                if(progress < 100){
                    getProgress();
                }else{
                    // All done
                    alert('done'); 
                }  
            }
        });
    }
    
    jQuery('#myForm').submit(function(form) {
        form.preventDefault();
        // Only go if we aren't currently.
        if(progress == null || progress == 100){
            increment = (jQuery("input#increment").val())*1;
            total = jQuery("input#total").val();
            progress = 0;
            getProgress();
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have heard from a friend of mine that the best algorithm for swapping
Posting this one for a friend. They have an Icefaces app that uses Icefaces's
I have a friend that is starting up a new project. He wants to
My friend has a search engine that he wants to have a widget access
I have a friend that has a little bit of a holiday coming up
My friend says that Django only has 1 thread or something? And I have
I have a friend who wants something quite easy : he has a mac,
I have a friend that has been in the advertising industry for 20 years
I have a client that is using WP for a CMS. He wants un-registered
I have a set of mysql data that i want to share to a

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.