Calling a function from a ajax response content
- by pistolshrimp
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!