javascriptjqueryajaxonchangekeyup

How do I make the ajax run?


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);
                        }
                      }
                    );
      });

Solution

  • You can Try using the below.

    $(document).on('keyup change', '#formMenu', function() {
      // Your Ajax Call here
    })