Facebook seems to have addressed this problem brilliantly: an AJAX component has been created within the system to handle all the AJAX requests. If you follow the traditional MVC approach and all your requests are routed to the main
index.php file, then you have two options:
- use a robust framework to handle AJAX requests (e.g. Zend)
- implement a custom system to detect and process AJAX requests.
http://example.com/?view=user&id=10, so you don't have to worry too much about this. All you need to do is to tell to your client-side developer(s) to redirect all AJAX calls to the main
index.php file. Your
- send the request
- receive the response
- process/display the response.
For debugging purposes, it's better to work with normal requests first. You should add AJAX only when you're sure that a given URL will be interpreted correctly, processed correctly and that it will return a proper and meaningful response. For example, if your PHP code returns a MySQL error, AJAX won't show anything in most cases, so you need first to check out whether your code is correct or not.