Results 1 to 3 of 3

Thread: Dynamic Ajax Content and JQuery Script.

  1. #1
    Join Date
    Feb 2012
    Posts
    36
    Thanks
    16
    Thanked 1 Time in 1 Post

    Default Dynamic Ajax Content and JQuery Script.

    1) Script Title: Dynamic Ajax Content

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...jaxcontent.htm

    3) Describe problem: I need to use JQuery on an HTML page to toggle the Div on the page. That HTML page is being loaded onto another page using the Dynamic Ajax Content script. I am hoping to find a way to use JQuery with Ajax, as I understand the two aren't really all that compatible.

    The HTML page with the JQuery code is here (working script): http://www.torontoclassfind.com/deta...tyourroom.html

    The HTML page I am loading the other page onto is here (script not working): http://www.torontoclassfind.com/startpage.html

    The menu list of building names will ultimately be links that will change the ajax page in the bottom left div. But for now I just have the one page being loaded into the lower left Div by default.

    Any input on this would be appreciated !

    Edit: Question has been answered and the content on the links posted have changed (just a note for future viewers of this thread who click the links and don't 'get' what my problem was).
    Last edited by GSimon; 12-15-2012 at 03:21 AM.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,925
    Thanks
    43
    Thanked 3,187 Times in 3,151 Posts
    Blog Entries
    12

    Default

    Not only do jQuery and AJAX get along, jQuery does AJAX, and in a much more robust manner than the Dynamic Ajax Content script. jQuery also has other ways of dealing with imported content from other scripts like Dynamic Ajax Content that are more cumbersome to setup using ordinary javascript alone.

    A problem with any AJAX imported content that has scripts on it is that you are not going to get the onload or document ready events that you get when it's a standalone page. And often scripts on the imported page are not imported with it. If you use one of jQuery's AJAX functions you can specify a success function to run. It varies as to how this is best setup, but generally you would put the jQuery code you're using on the 'top' page and the document ready event for the external page becomes or becomes part of the success function of the jQuery AJAX method you're using.

    There's another way for something as simple as what you're doing. On the 'top' page, add the highlighted as shown:

    Code:
     <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
            
            		<script type='text/javascript'> 
    
    			$('#firstfloor').live('click', function() {
    			    $("#hello").toggle(this.checked);
    			});
    
                    	$(function(){
                    
                            $('#MenuList1').click(function() {
                                    $('#BuildingsList1').show();
                                    $('#BuildingsList2').hide();
                                    $('#Buildings . . .
    Using jQuery's live method you can assign behavior(s) to an element or elements that haven't arrived yet.

    For more information on .live(), see:

    http://api.jquery.com/live/
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    GSimon (12-14-2012)

  4. #3
    Join Date
    Feb 2012
    Posts
    36
    Thanks
    16
    Thanked 1 Time in 1 Post

    Default

    Thanks John! That did the trick.

    I was avoiding the idea of including the JQuery on the top page because (aside from thinking it wouldn't work for some reason) I am trying to export as much coding onto the Ajax pages as possible, and figured including it in the top page might get to cluttered. However the line of code I'm using is relatively short and I should be able to re-use the same code for multiple pages with the same script, so it's not an issue as I thought it might of been.

    I'll look into the .live element also, am in the process of learning JQuery currently so hopefully I can wrap my head around some of the more obscure elements (to me at least) soon.

    Sent you a tip

Similar Threads

  1. jQuery UI Accordion with Dynamic Ajax Content
    By Lestatt in forum Dynamic Drive scripts help
    Replies: 3
    Last Post: 05-31-2012, 08:46 AM
  2. Dynamic Ajax Content with jquery plugins
    By ale3andros in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 03-19-2012, 06:51 PM
  3. Dynamic Ajax Content not loading jquery on pages being loaded
    By cmccarra in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 03-21-2010, 01:42 PM
  4. Dynamic Ajax Content - Jquery SlideDown Buttons
    By helius in forum JavaScript
    Replies: 0
    Last Post: 06-23-2009, 03:27 PM
  5. Dynamic Ajax Content - Jquery SlideDown Buttons
    By helius in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 06-22-2009, 03:18 PM

Bookmarks

Posting Permissions

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