You need to protect this server side, you cannot protect it on the client side, and you should not.
JavaScript is viewable, executable, dynamic, open ... that's all you would like to do ... well, whatever you want with it, which is very bad for security. You need to check the passed identifier with which the user must have access on the server when processing the request.
Everything, and I mean that everything you do on the client is a deterrent, not a solution, and in fact there are no effective JavaScript restraints that I have ever seen. Even if you can protect it, I can simply open Firebug, Fiddler, Wireshark, the Chrome console, or one of a dozen other tools to see what the request ultimately sends.
Nick craver
source share