JavaScript XMLHttpRequest() to a PHP file always returns same data

one text

Solution:

I am currently looking into XMLHttpRequest() myself. Noticed the topic is almost two years old already, but maybe it's still useful to someone coming across this.

W3Schools has something that might be relevant to your issue: https://www.w3schools.com/xml/ajax_xmlhttprequest_send.asp

GET or POST?

GET is simpler and faster than POST, and can be used in most cases.

However, always use POST requests when:

  • A cached file is not an option (update a file or database on the server).
  • Sending a large amount of data to the server (POST has no size limitations).
  • Sending user input (which can contain unknown characters), POST is more robust and secure than GET.

Sounds to me you are running into some caching issues. Give the POST method a spin and see if that works. Hope that helps!

Source