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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:35:55+00:00 2026-06-01T16:35:55+00:00

I have a application which you can access here . If you open the

  • 0

I have a application which you can access here. If you open the application please click on the “Add” button a couple of times. This will add a new row into a table below. In each table row there is an AJAX file uploader.

The problem I have is that if you click on the “Upload” button, it shows a loading bar but the problem is that the loading bar just doesn’t go away. What was suppose to happen is that the user clicks on ‘Upload’ and then it will display the file input again and buttons with a message above stating whether file was successfully loaded or not?

Why is the loading bar never stop loading and how can I fix this?

Below is the code of the file input appended in each row and the javascript functions which it is suppose to start and stop the uploading:

<script type="text/javascript">


function insertQuestion(form) {   

    var $tbody = $('#qandatbl > tbody'); 
    var $tr = $("<tr class='optionAndAnswer' align='center'></tr>");
    var $image = $("<td class='image'></td>"); 


var $fileImage = $("<form action='upload.php' method='post' enctype='multipart/form-data' target='upload_target' onsubmit='startUpload(this);' >" + 
    "<p class='f1_upload_process' align='center'>Loading...<br/><img src='Images/loader.gif' /><br/></p><p class='f1_upload_form' align='center'><br/><label>" + 
    "File: <input name='fileImage' type='file' class='fileImage' /></label><br/><label><input type='submit' name='submitBtn' class='sbtn' value='Upload' /></label>" +
    "</p> <iframe class='upload_target' name='upload_target' src='#' style='wclassth:0;height:0;border:0px solclass #fff;'></iframe></form>");

    $image.append($fileImage);

    $tr.append($image);  
    $tbody.append($tr); 

}

function startUpload(source_form){
  $(source_form).find('.f1_upload_process').css('visibility','visible');
  $(source_form).find('.f1_upload_form').css('visibility','hidden');
      return true;
}

function stopUpload(success, source_form){
      var result = '';
      if (success == 1){
         result = '<span class="msg">The file was uploaded successfully!<\/span><br/><br/>';
      }
      else {
         result = '<span class="emsg">There was an error during file upload!<\/span><br/><br/>';
      }
      $(source_form).find('.f1_upload_process').css('visibility','hidden');
      $(source_form).find('.f1_upload_form').html(result + '<label>File: <input name="fileImage" type="file"/><\/label><label><input type="submit" name="submitBtn" class="sbtn" value="Upload" /><\/label>');
      $(source_form).find('.f1_upload_form').css('visibility','visible');     
      return true;   
}
</script>
  • 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-01T16:35:56+00:00Added an answer on June 1, 2026 at 4:35 pm

    Your upload.php file is not passing in the source_form parameter for the stopUpload() function. This is what your PHP file is returning:

    window.top.window.stopUpload(0);
    

    It has the success parameter but nothing for source_form. So these three lines of code in stopUpload() are not going to work right, because source_form is going to be undefined:

    $(source_form).find('.f1_upload_process').css('visibility','hidden');
    $(source_form).find('.f1_upload_form').html(result + '<label>File: <input name="fileImage" type="file"/><\/label><label><input type="submit" name="submitBtn" class="sbtn" value="Upload" /><\/label>');
    $(source_form).find('.f1_upload_form').css('visibility','visible');  
    

    I’ve put together a fix that should work:

    <script type="text/javascript">
     var sourceForm; 
    
    function insertQuestion(form) {   
    
        var $tbody = $('#qandatbl > tbody'); 
        var $tr = $("<tr class='optionAndAnswer' align='center'></tr>");
        var $image = $("<td class='image'></td>"); 
        var $fileImage = $("<form action='upload.php' method='post' enctype='multipart/form-data' target='upload_target' onsubmit='startUpload(this);' >" + 
        "<p class='f1_upload_process' align='center'>Loading...<br/><img src='https://helios.hud.ac.uk/u0867587/Mobile_app/Images/loader.gif' /><br/></p><p class='f1_upload_form' align='center'><br/><label>" + 
        "File: <input name='fileImage' type='file' class='fileImage' /></label><br/><label><input type='submit' name='submitBtn' class='sbtn' value='Upload' /></label>" +
        "</p> <iframe class='upload_target' name='upload_target' src='#' style='wclassth:0;height:0;border:0px solclass #fff;'></iframe></form>");
    
        $image.append($fileImage);
    
        $tr.append($image);  
        $tbody.append($tr);      
    }
    
    function startUpload(source_form){
      $(source_form).find('.f1_upload_process').css('visibility','visible');
      $(source_form).find('.f1_upload_form').css('visibility','hidden');
      sourceForm = source_form;
      return true;
    }
    
    function stopUpload(success){
          var result = '';
          if (success == 1){
             result = '<span class="msg">The file was uploaded successfully!<\/span><br/><br/>';
          }
          else {
             result = '<span class="emsg">There was an error during file upload!<\/span><br/><br/>';
          }
          $(sourceForm).find('.f1_upload_process').css('visibility','hidden');
          $(sourceForm).find('.f1_upload_form').html(result + '<label>File: <input name="fileImage" type="file"/><\/label><label><input type="submit" name="submitBtn" class="sbtn" value="Upload" /><\/label>');
          $(sourceForm).find('.f1_upload_form').css('visibility','visible');     
          return true;   
    }
    </script>
    

    This starts by creating a new global variable called sourceForm at the very top of the block. This variable will be used to store which form the user clicked the upload button on, it is set in the startUpload() function:

    sourceForm = source_form;
    

    So as soon as the user hits Upload we will have a reference to the form they are using through the sourceForm variable. Then in stopUpload() you just use that new sourceForm variable to update the visibility and set the return message.

    As a side note, you should really look into using jQuery ajax(). Using the iframe to run the JavaScript from your PHP file seems kind of difficult and cumbersome. The ajax() method is so much easier.

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

Sidebar

Related Questions

I have an application you can access here When you open the app, please
I have a jsfiddle application which you can access here . Now when you
I have a console application which can also open winform under certain conditions.Processing(its a
I have an application in which you can accept friend request. For this purpose
I have a base class, which includes all other files. I can access this
I have an application which requires authentication, but has some related services which can
We have a delphi application which can also run as a sevice . We
I have a socket application which I can use in local network, at home.
I have two async classes in my application which you can see below class
I have a console application from which I create a window. I can render

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.