I have been studying ajax, in different videos from youtube and in different pages, now my question is always the script in which ajax is going to be in the .html I always see it there, and for example I tried to pass it to another side like a .js file but it does not load anything to me only when I leave it inside the label of the .html (code js and ajax) it works to me. Is this good practice? That's wrong ? why?
here is the code that is at the end of my body at the html point.
and here is the code that is inside simulate.js
As a result, it directs me to a php page. but if I leave it inside the html if it gives me the same data in the same html.