Q:

Where to put PHP files for AJAX in MVC architecture?

I'm creating site using MVC architecture and get stunned when I came to AJAX. I create simple feedback form with AJAX. When user submit it there is called PHP file that inserts given values into the database using 'database' class.
Where to put that PHP file (so it would be somehow hierarchic)?
I tried to put it in /models/ajax/file.php, but it seems to me stupid and, of course, 'database' class wasn't found.

A:

It's no different than how you do any other page of your site. That this page's output goes to an AJAX request instead of directly to a web browser is irrelevant. Its logic goes in the controller, the database code goes in the model layer, its response goes in a view.

