I am new to JavaScript and I am facing an issue with my AJAX function. The function is supposed to navigate to a new URL, but instead of loading the new page separately as if the user had typed the URL, it gets inserted inside the same div where the button was clicked to launch the script using its onclick handler. Here is the line causing the problem:
window.location.href("newpage.html");
What I actually want is for the old page to be replaced by the new page while keeping the old page in the browsing history.
It's worth mentioning that this script is triggered by a button inside a form. I can provide more code if needed.
Thank you!