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
    Nov 2009
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    jQuery and ajax load works once, stop working

    I posted this in the ajax forum, I think it belongs here...sorry

    I could really use some help, I'm new to jQuery

    Basically I have a calendar with a link to go to the next or previous day. What i have below works once, but once the ajax page loads it stops working.

    Code:
    <script language="javascript">
    $(document).ready(function() {
    	$.ajaxSetup ({
    		cache: false
    	});
    	var ajax_load = "<img src='images/ajax.gif' alt='loading...' />";
    	
    //	load() functions
    	var loadUrl = "includes/cal.php";
    	$("#load").click(function(){
    		$("#cal_content").html(ajax_load).load(loadUrl, { 'option': ["tom"] } );
    
    	});
    
    });
    </script>
    
    <div id="cal_content">
    
         <a href="#" id="load">Next</a>
    
    </div>
    
    // includes/cal.php
    
    <div id="cal_content">
    
    <? if($_POST['option']...blah blah blah ?>
    
         <a href="#" id="load">Next</a>
    
    </div>

    Obviously there's a lot more code in these files I did not include, but that's what you need to know. It is loading cal.php into the dom just fine, but once it's in there, it doesn't work. I've tried using class instead of id values, but it does the same thing.

    Can anyone help me please?

  • #2
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    Double-posting is frowned upon. If you can't delete this thread, you might want to PM a mod and ask for a removal. I've posted a response over in the AJAX subforum.
    Are you a Help Vampire?

  • #3
    New to the CF scene
    Join Date
    Nov 2009
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    yea, as i said in the beginning of this post, i'm sorry for the double post, i did not see a frameworks forum. This can be deleted, thanks for your help in the other thread tomws!

  • #4
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    The cause of your problem is the same culprit as I explain in this thread:

    jquery toggle/hide problem

    If you use the .live(click) function rather than the .click() function you should on your way.


  •  

    Posting Permissions

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