Level 59
I'm not sure what you mean. If it correctly updates the #myDiv element, then the DOM has been updated.
I have the following ajax call:
$("#searchField").on('keyup', function(){
var value = $(this).val();
$.ajax({
type : 'get',
url : 'livesearch',
data : {
search:value
},
success : function(data){
console.log(data);
$('#myDiv').html(data);
}
});
});
It updates the myDiv element but DOM does not change.
How do I update the DOM?
If I understand you correctly, it's because the event handlers are no longer attached after you update the DOM. Event delegation is the solution.
https://learn.jquery.com/events/event-delegation/#event-propagation
Please or to participate in this conversation.