Ajax (Asynchronous Javascript And Xml) is an abbreviation meaning the technology of sending a request to a web server without reloading the page. At the root of this technology is a JavaScript object XMLHttpRequest , which sends a normal HTTP request to the server, no different from any other, performed by means of any tool (navigating through the address line of the browser or the CURL utility)
Can an attacker send a POST request directly and thus change the setting in the system?
When you design an API backend (the so-called server part, in your case ajax.php), you need to understand that anyone can access this API (in the case of a public network, such as the Internet). In order to protect private information (settings, in your case), you need to organize user authorization .
A common scenario could be the following:
- User authentication on the server (your or trusted) by sending some authorization data, such as login and password.
- Getting the key on this server
- Sending this key along with a request to the server to perform some useful action (in your example to ajax.php)
The server should check such a key for its belonging to a specific authorized user and allow / prohibit the processing of the request depending on the result of the check.