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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T14:01:11+00:00 2026-05-19T14:01:11+00:00

I have a piece of code in jQuery that I use to get the

  • 0

I have a piece of code in jQuery that I use to get the contents of an iFrame after you click a link and once the content is completed loading. It works, but I have a problem with it repeating – at least I think that is what it is doing, but I can’t figure out why or how.

jQuery JS:

 $(".pageSaveButton").bind("click",function(){
   var theID = $(this).attr("rel");
   $("#fileuploadframe").load(function(){
     var response = $("#fileuploadframe").contents().find("html").html();
     $.post("siteCreator.script.php",
        {action:"savePage",html:response, id: theID},
         function(data){
           alert(data);
         });
   });
 });

HTML Links ( one of many ):

<a href="templates/1000/files/index.php?pg=0&preview=false" 
       target="fileuploadframe" class="pageSaveButton" rel="0">Home</a>

So when you click the link, the page that is linked to is opened into the iframe, then the JS fires and waits for the content to finish loading and then grabs the iframe’s content and sends it to a PHP script to save to a file. I have a problem where when you click multiple links in a row to save multiple files, the content of all the previous files are overwritten with the current file you have clicked on. I have checked my PHP and am pretty positive the fault is with the JS.

I have noticed that – since I have the PHP’s return value alerted – that I get multiple alert boxes. If it is the first link you have clicked on since the main page loaded – then it is fine, but when you click on a second link you get the alert for each of the previous pages you clicked on in addition to the expected alert for the current page.

I hope I have explained well, please let me know if I need to explain better – I really need help resolving this. 🙂 (and if you think the php script is relevant, I can post it – but it only prints out the $_POST variables to let me know what page info is being sent for debugging purposes.)

Thanks ahead of time,
Key

  • 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-19T14:01:12+00:00Added an answer on May 19, 2026 at 2:01 pm

    From jQuery .load() documentation I think you need to change your script to:

    $(".pageSaveButton").bind("click",function(){
        var theID = $(this).attr("rel");
        var lnk = $(this).attr("href");//LINK TO LOAD
        $("#fileuploadframe").load(lnk,
            function(){ 
            //EXECUTE AFTER LOAD IS COMPLETE
                var response = $("#fileuploadframe").contents().find("html").html();
                $.post("siteCreator.script.php",
                    {
                        action:"savePage",
                        html:response, 
                        id: theID
                    },
                    function(data){alert(data);}
                );
        });
    });
    

    As for the multiple responses, you can use something like blockui to disable any further clicks till the .post call returns.

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

Sidebar

Related Questions

I have a piece of jQuery code that fills an element on the page
I have quite a complex piece of code (JQuery and HTML5 Web SQL) that
I have a piece of code (below) that can get the text of an
I have a piece of jQuery code that queries a page via POST and
In jQuery, I have written a piece of code that appears on every page
I have a piece of jquery code that isn't firing correctly in IE (8
I have this simple piece of code in jQuery $(document).ready(function() { $('#switcher').click(function(event) { if
I have this piece of code: $(#faq).click(function () { var url = $.get(faq, {
So I have a piece of code: jQuery.fn.center = function(parent) { parent = this.parent();
I'm using jQuery with rails and have the following piece of code $('#related').html(<%= 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.