jQuery Ajax() doesn’t work when the page is accessed as a WordPress template page
I advice to use the wp built-in ajax. it allows avoiding many problems and brings many benefits. an example that I wrote to illustrate the 2 approches: Dynamically changing navigation links (next and previous) via AJAX I am here to provide with explanations good luck