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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T19:49:56+00:00 2026-05-18T19:49:56+00:00

Hi the below Javascript is called when I submit a form. It first splits

  • 0

Hi the below Javascript is called when I submit a form. It first splits a bunch of url’s from a text area, it then:

1) Adds lines to a table for each url, and in the last column (the ‘status’ column) it says “Not Started”.
2) Again it loops through each url, first off it makes an ajax call to check on the status (status.php) which will return a percentage from 0 – 100.
3) In the same loop it kicks off the actual process via ajax (process.php), when the process has completed (bearing in the mind the continuous status updates), it will then say “Completed” in the status column and exit the auto_refresh.
4) It should then go to the next ‘each’ and do the same for the next url.

function formSubmit(){

    var lines = $('#urls').val().split('\n');

    $.each(lines, function(key, value) {
        $('#dlTable tr:last').after('<tr><td>'+value+'</td><td>Not Started</td></tr>');
    });

    $.each(lines, function(key, value) {

        var auto_refresh = setInterval( function () {
            $.ajax({
              url: 'status.php',
              success: function(data) {
            $('#dlTable').find("tr").eq(key+1).children().last().replaceWith("<td>"+data+"</td>");
              }
            });
        }, 1000);

        $.ajax({
          url: 'process.php?id='+value,
          success: function(msg) {
        clearInterval(auto_refresh);
        $('#dlTable').find("tr").eq(key+1).children().last().replaceWith("<td>completed rip</td>");
          }
        });

    });

}
  • 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-18T19:49:57+00:00Added an answer on May 18, 2026 at 7:49 pm

    What you want is to run several asynchronous actions in sequence, right? I’d build an array of the functions to execute and run it through a sequence helper.

    https://github.com/michiel/asynchelper-js/blob/master/lib/sequencer.js

    var actions = [];
    $.each(lines, function(key, value) {
    
        actions.push(function(callback) {
          $.ajax({
              url: 'process.php?id='+val,
              success: function(msg) {
                clearInterval(auto_refresh);
    
                //
                // Perform your DOM operations here and be sure to call the
                // callback!
                //
    
                callback();
              }
            });
        });
      }
    );
    

    As you can see, we build an array of scoped functions that take an arbitrary callback as an argument. A sequencer will run them in order for you.

    Use the sequence helper from the github link and run,

    var sequencer = new Sequencer(actions);
    sequencer.start();
    

    It is, btw, possible to define sequencer functions in a few lines of code. For example,

    function sequencer(arr) {
        (function() {
            ((arr.length != 0) && (arr.shift()(arguments.callee)));
        })();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have example of code below. <script type=text/javascript src=assets/scripts/somescript.php>. </script> So, will my browser
How would I achieve the pseudo-code below in JavaScript? I want to include the
The below HTML/CSS/Javascript (jQuery) code displays the #makes select box. Selecting an option displays
Does anyone know how to get the below to report a javascript error? (any
Below are two ways of reading in the commandline parameters. The first is the
Below I have a very simple example of what I'm trying to do. I
Below is my current char* to hex string function. I wrote it as an
Below is part of the XML which I am processing with PHP's XSLTProcessor :
Below is my $.ajax call, how do I put a selects (multiple) selected values
Below is the code of a simple html with a table layout. In FF

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.