When I add the ajax it only runs once.
I try that when I enter a letter in the search engine or change a select field, it sends me the new search to display it on the screen.
formMenu is a form containing a select and an imput text.
$('#formMenu').on('keyup change',function() {
$.ajax(
{
url: '/calendar',
success: function( data ) {
$('body').html(data);
}
}
);
});
2
Answers
You instance of
#formMenu
is not existing after you replace the body even if the same element exists in the new body its still a different instance.You have to register the listener on the highest parent that is not replaced (in this case the body):
You can Try using the below.