Modifying URL Search Query With JavaScript
I am using JavaScript to paginate a data set with ajax, and once the result is returned, I update the query string with the current query by modifying the history.
const replaceQueryString = newQueryString => {
window.history.pushState(null, '', `?${newQueryString}`);
};
This part works fine and does what I want, which is modifying the string in the URL without actually reloading the page. I want the page to reload when the back button is used so that the previous query can be executed again. Currently the query string does change back to the previous one when I press the back button, but the page does not reload and nothing happens.
Is there something I'm missing here or need to listen to? Or is it just not possible to do this?
Please or to participate in this conversation.