in reply to How to store the value of a Javascript function as a Perl variable
One final comment that I would make, regarding the OP’s proposed design, is that it is probably not a good idea for the GET/POST to refer to, say, “testScript.cgi,” unless this is the name of the entire web-site. Don’t make the client-side knowledgeable about how the host-side is organized, and particularly, don’t let the JavaScript (nor any “script kiddie”) call whatever it wants to. Instead, send all requests to a single, fairly-opaque URL (say, “mysite.com/api), sending a JSON-formatted request (including some kind of “request name” parameter), and receiving a similar response. Success gets a 200 return-code and a JSON packet; Failure gets 500 and a different, but standard, JSON packet.
For ideas on the server-side, look at RPC::Any::Server. (Whether you literally use that code or not, carefully observe the approach.) It is, at its heart-of-hearts, “a remote procedure-call,” and it should be treated as such. The client may ask the host to do something on its behalf, but should not be permitted to tell the host what to do nor exactly how to do it.
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to store the value of a Javascript function as a Perl variable
by Anonymous Monk on Jun 24, 2014 at 20:13 UTC |