Reputation: 149
I would like to fill out a div created through an AJAX request using jQuery.
It seems that I can't do it since my new DIV isn't in the DOM at the time I bind the event. Here is my code:
function updateNotice(content, type) {
noticeName.html(content).addClass(type).show("slow");
}
noticeName
is set to $( "#form-notice" );
in a global variable. But form-notice
is a div that is sent from another ajax request (called before the one above), how can I fill it? Should I use jQuery.on()? How to use it?
Upvotes: 0
Views: 806
Reputation: 937
You need to do this $( "#form-notice" ); after the html you get from your ajax call is rendered.
function updateNotice(content, type) {
noticeName = $( "#form-notice" );
noticeName.html(content).addClass(type).show("slow");
}
Upvotes: 2