Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    May 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Multiple Instances of External Page - Ajax

    Hi folks, I am experimenting on this Ajax Page Fetcher and it's been really nice.

    http://www.javascriptkit.com/script/...efetcher.shtml

    I just would like to ask for your advice as to how would I be able to make it to work for multiple instances of SAME div id? I know I have to rename another div with a new id, but I just thought to ask you if there's a way to get around it? Because the external page won't load inside the other div.

    Is there other way? Thanks for any inputs.


    something like below.

    Code:
    <div id="joe"></div>
    <script type="text/javascript">
    // Fetch and display "content.htm" inside a DIV automatically as the page loads:
    ajaxpagefetcher.load("joe", "content.htm", true)
    </script>
    
    
    <div id="joe"></div>
    <script type="text/javascript">
    // Fetch and display "content.htm" inside a DIV automatically as the page loads:
    ajaxpagefetcher.load("joe", "content.htm", true)
    </script>

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,391
    Thanks
    11
    Thanked 568 Times in 561 Posts
    Isn't the first parameter of .load() actually the ID of the destination element? So when you change the ID of the second DIV to let's say "john" and at the same you change the first parameter of the second .load() call to "john", doesn't it just work?
    Code:
    <div id="joe"></div>
    <script type="text/javascript">
    // Fetch and display "content.htm" inside a DIV automatically as the page loads:
    ajaxpagefetcher.load("joe", "content.htm", true)
    </script>
    
    
    <div id="john"></div>
    <script type="text/javascript">
    // Fetch and display "content.htm" inside a DIV automatically as the page loads:
    ajaxpagefetcher.load("john", "content.htm", true)
    </script>

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    By short: no. id must be unique on document.
    Last edited by Kor; 05-19-2011 at 01:13 PM.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #4
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,391
    Thanks
    11
    Thanked 568 Times in 561 Posts
    Ok, it's very similar to one of the official examples on the mentioned documentation page
    Code:
    <div id="joe"></div>
    
    <script type="text/javascript">
    // Fetch and display "content.htm" inside a DIV automatically as the page loads:
    ajaxpagefetcher.load("joe", "content.htm", true)
    </script>
    
    <div id="bob"></div>
    
    <script type="text/javascript">
    <!-- Fetch and display "sub/content2.htm" inside a DIV when a link is clicked on. Also load one .css file-->
    ajaxpagefetcher.load('bob', 'sub/content2.htm', false, '', ['page.css']);
    </script>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •