What is the standard practise with PHP pages that are used for Ajax requests? Should they print out a single value (ex: get points of player with id = x)? Does/should a single page serve multiple requests? If so, how can code be grouped on the PHP side?
P.S: An additional question: If a templating system like Smarty is used, would it be more interesting security-wise to call the PHP page being used instead of calling the request page directly?
I use this piece of code in Javascript. Backend wise things are organized in a MVC type of organisation, so things affecting one module are usually grouped together. In general I also create a sperate module for a seperate model, but in some cases you may deviate from this principle.
PHP
Execute a piece of code and wrap it inside a try/catch block. This way error messages may be propagated to the frontend. This method helps in that regard to convert exceptions to a readable error. (to debug from json).
For error handling I often use this to parse errors.
Javascript side
Note: the error callbacks are very nice if you combine them with something like pNotify