Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-19-2011, 10:32 AM   PM User | #1
pacmanny2
New to the CF scene

 
Join Date: May 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
pacmanny2 is an unknown quantity at this point
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>
pacmanny2 is offline   Reply With Quote
Old 05-19-2011, 10:56 AM   PM User | #2
devnull69
Senior Coder

 
Join Date: Dec 2010
Posts: 2,261
Thanks: 10
Thanked 533 Times in 527 Posts
devnull69 will become famous soon enough
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>
devnull69 is offline   Reply With Quote
Old 05-19-2011, 11:12 AM   PM User | #3
Kor
Red Devil Mod


 
Kor's Avatar
 
Join Date: Apr 2003
Location: Bucharest, ROMANIA
Posts: 8,478
Thanks: 58
Thanked 379 Times in 375 Posts
Kor has a spectacular aura aboutKor has a spectacular aura about
By short: no. id must be unique on document.
__________________
KOR
Offshore programming
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

Last edited by Kor; 05-19-2011 at 01:13 PM..
Kor is offline   Reply With Quote
Old 05-19-2011, 11:25 AM   PM User | #4
devnull69
Senior Coder

 
Join Date: Dec 2010
Posts: 2,261
Thanks: 10
Thanked 533 Times in 527 Posts
devnull69 will become famous soon enough
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>
devnull69 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:47 AM.


Advertisement
Log in to turn off these ads.