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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:49:08+00:00 2026-06-18T11:49:08+00:00

I am trying to create a jquery function that is going to import XML

  • 0

I am trying to create a jquery function that is going to import XML data to a wordpress site. During the process I want it to individually import posts then update a progress bar and/or counter each time an import finishes.

The problem I have is that the progress updates all seem to be held back until the entire process is finished and then update all at the same time.

For example: rather than updating the page with 1/100 complete, then 2/100 complete, it waits to the end and then adds all 100 updates at the same time.

Hopefully my code will explain it better than I have :S

// Send inital data to check XML feed
$.ajax({
    url: ajaxurl,
    type: 'POST',
    data: ajaxdata
}).done( function(response) {

    ...

    // Process XML data
    $('#progress').html('<h3>Import Progress</h3><p id="import_status"></p>');

    data2 = $("#form_name").serialize();

    finished = false;
    count = 0;

    while (!finished) {

        var ajax = $.ajax({
            url: ajaxurl,
            data: data2,
            type: 'POST',
            async: false
        }).done(
            function(response2) {
                if (response2 == 0) {
                    finished = true;
                } else {
                    count++;
                    split = response2.toString().split("::");
                    $('#progress').append('<p><strong>Item'+count+'/'+split[0]+'</strong><br/><strong>Status:</strong> '+split[1]+'</p>');
                    if (count >= split[0]) {
                        finished = true;
                    }
                }
            }
        );

    } // while

    $('#progress').append('<p>Import Complete!</p>');

    ...

}

The php file at ajaxurl is returning what it should in the right places. For context, during the while loop, the php file returns a string like this:

    100::Some Status Information

where 100 is the total number of lines that will be returned.

The loop runs the correct number of times and outputs all right information when it’s complete… but it doesn’t output item by item… it outputs all at the same time.

What am I missing? How can I get this to output each items status report individually?

Thanks for any help you can offer.

EDIT: Just some extra information, the <h3>ImportProgress</h3> doesn’t appear until AFTER the while loop is completed either! The whole lot appears at once!

  • 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-18T11:49:09+00:00Added an answer on June 18, 2026 at 11:49 am

    From what I understand Javascript runs in a single thread, so the while iteration blocks the execution and rendering of your page.

    In order to show progress in Javascript while a process is running you should refactor your code, the following answer shows a way to do just that: Show javascript execution progress.

    Hope it helps.

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

Sidebar

Related Questions

I'm trying to create a JQuery function that will test a string for the
I am trying to create a jQuery hover function that will highlight a different
Can anyone advise on this? I'm trying to create a jquery function that will
I'm trying to create a jquery function that can be called both on ready
I am trying to create a jQuery function that will take a string and
I'm trying to create a function that uses jQuery to get height of image,
I'm trying to create a popup for which I am using jQuery's CSS function.Here's
I am trying to create a jQuery Gallery that lets the user flip (with
I'm trying to create a jQuery selector that will do something like this: (.a
I'm trying to create some jQuery UI Tabs using data fetched from a database.

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.