Calling a function from a ajax response content
        Posted  
        
            by pistolshrimp
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by pistolshrimp
        
        
        
        Published on 2010-05-29T23:30:19Z
        Indexed on 
            2010/05/29
            23:32 UTC
        
        
        Read the original article
        Hit count: 179
        
Hi guys.
I have a function when the page is ready.
<script> 
$(function(){
  function do_ajax(){
  do some stuff
  }
});....
This works great on that page. Then I make a .post call and load the response into a div. The response has a
<script>$(selector).click(function(){ do_ajax(); });</script>
with the result. I get an error "do_ajax() is undefined". How can I call do_ajax() from an event from the ajax content?
Another one.
I am using jquery ui datepicker. So, when the page is loaded, I invoke the
$(".datepicker").datepicker();
This works great on that page. Then I make a .post call and load the response into a div. The response has a couple of .datepicker fields. The problem is that the newly loaded datepicker fields don't get the calendar unless I return
<script>$(".datepicker").datepicker();</script>
with the result. Is that how you guys do it or is there another way?
Thanks!
© Stack Overflow or respective owner