Here is one way that is quite simple (although not trivial) to implement and very difficult to crack and not so easy to crack.
On the server side there is a list of let say 1000 items stored in a text file or database.
Each element will be a unique GUID or other unique long string, let each key element be called.
Now, when you send an AJAX request, send one of these keys ... it may be random from the list or by increasing the index, it does not matter.
Now comes the nice part: after one โuseโ of each key (which means that the server received a request with this key and answered it), delete the key from the file / database . If the server receives a request with a key that does not exist in the list, of course, run an error or return the line โwithout hackingโ.
When the list becomes empty, recreate it with new unique keys.
Thus, the first request with a real key should succeed, as usual, but if the user tries to call the same request again, it will fail. Guessing the keys is also very difficult, assuming that these are long random values.
Like any other method, it is corrupted due to the fact that depending on the client-side code, which can be faked by those who know how to do it. But, since this is not a common occurrence, it will be more difficult for difficult people to find how it works and hack it.
Shadow wizard
source share