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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:11:04+00:00 2026-06-09T05:11:04+00:00

UPDATE: I was mislead, by some mistake I had made, into thinking that I

  • 0

UPDATE:

I was mislead, by some mistake I had made, into thinking that I could not both have a running script updating the screen AND an outstanding submit that would reload the page upon completion.

You can do this, and I have. The way that I did it was to place my updater on a startTimeout and let the submit continue.

    $('#JQF').on('submit', function(){
      start();
      return true;
    });
...
start: 
  function (xhr, s) {
    $(".appMainMsg").hide();
    bar = document.getElementById("ProgressBar");
    if (bar)
    {
      eta = document.getElementById("ProgressBarEta");
      startTime = new Date();
      infoUpdated = 0;
      infoRequested = 0;

      $(bar).empty().progressbar();
      setTimeout(requestInfo, 2);
    }
  },
...

ORIGINAL Question:

I have a page that posts a form with file uploads and targets the response to an hidden iframe. When the iframe finishes loading, it calls a function in the (main) page. If all looks good, I want to move the contents of the body that loaded into the iframe to the main page’s body, else I will just leave things alone. I do have jquery loaded so I’d like to use that.

<body>
  <iframe name='ifr' id='ifr' style='display: none;'></iframe>
  <form target='ifr' method='post' action='mypage.php'>
  </form>
  <script>
  function finished()
  { if (iLikeIt) 
    { 
      //replace body contents with ifr.body.contents
      // keeping all event handlers attached
      // something like...

      WHAT DO I PUT HERE?
    }
  }
  </script>
</body>

The page loaded into the iframe, ends with:

<script>
  setTimeout(parent.finished, 1000); // some time for navel gazing
</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-09T05:11:05+00:00Added an answer on June 9, 2026 at 5:11 am

    You do not need iframe to do this. I recommend to submit your form by ajax.
    Since you have jquery loaded, the easiest option for you is to use jquery-form plugin.

    Here is a working example of what you are looking for:

    index.html:

    <!doctype html>
    <html>
    <head>
        <script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
        <script src="http://malsup.github.com/jquery.form.js"></script>
        <script>
    
        $(function(){
    
            // instead of redirecting to upload.php, your form "#form"
            // will now be submitted by ajax and you'll get response
            // content in html parameter of success callback
            $('#form').ajaxForm({
                // you can handle "json" or "xml" content types too
                // @see http://jquery.malsup.com/form/#json
                dataType:  'text',
                success: function(html) {
    
                    // in case you want to replace your document
                    // content with the response content
                    $(document.body).html(html);
                }
            });
    
    
    
            // This is how you "keep all event handlers attached", with
            // live method instead of bind.
            // So if you have #btn2 element in ajax response, and you replace
            // document content with this ajax response, jquery will auto-bind
            // 'click' event on new #btn2 element
            // Note that you can also use bind, but you'll have to "re-bind"
            // the event manualy (inside "success" callback in this case).
            $("#btn2").live("click", function(){alert("button 2 clicked")});
    
        });
    
        </script>
    </head>
    <body>
        <h1>ajax form:</h1>
        <form id="form" action="upload.php" method="post"> 
            <input type="file" name="file" /> 
            <input type="submit" value="Submit File" /> 
        </form>
    
        <h1>keeping all event handlers attached exemple:</h1>
        <button id="btn2">click me</button>
    </body>
    </html>
    

    upload.php:

    <?php
    
        // here you handle your $_FILES, $_POST, $_GET ...
    
    
        // html response example:
        header('Content-Type: text/html; charset=utf-8');
        echo '<h1>This is your ajax html response:</h1>';
        echo '<button id="btn1">click me</button>';
        var_dump($_FILES);
        echo '<h1>keeping all event handlers attached exemple:</h1>';
        echo '<button id="btn2">click me</button>';
        echo '<script>
    
                $(function(){
    
                    // js event handler attached to #btn1
                    $("#btn1").bind("click", function(){alert("button 1 clicked")});
                });
    
            </script>';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

UPDATE: I made a mistake in my debugging - this question is not relavent
UPDATE 6/21/12 I have a form in rails that is working similar to an
Update I want to have an expression (XPath, or Regex Expression, similar) that can
Update: It is solved .. For some reason, the data is not getting inserted
UPDATE UPI_ATTRIBUTE SET SITE_INC ='0' WHERE USER_PROFILING_NAME IN ('CAR_IMPLICIT','CAR_EXPLICIT') Above is my query that
Update 2018 TL;DR; LaTEX for WPF https://github.com/ForNeVeR/wpf-math Original question I need to have a
UPDATE : A commenter told me to change some codes, this is the new
Update: I am sorry i pasted in list.xml twice by mistake, my question is
I have a mission critical Perl-CGI server-side application that I need to extend or
I have a SQL Server 2008 database which contains data that I need to

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.