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?
You need to do this $( “#form-notice” ); after the html you get from your ajax call is rendered.