I am currently learning jQuery and AJAX and was wondering about best practices for organization of the server-side scripts that handle the AJAX calls. Should I have a handler.php file which then routes the AJAX calls to other functions in different files? Or do you just put everything in one file and use a big switch{}? The system will likely expand in the future and I want to organize it in a way that scales.
I am currently learning jQuery and AJAX and was wondering about best practices for
Share
A routing file is the way to go, not just for your AJAX requests but for all actions that can be invoked within your system by a web request. You should be placing related actions into a single controller file, and then loading/invoking the correct file/method from your public-facing router.
A good framework, which you absolutely should be using, will do this for you.