Doubt regarding MVC

1

I'm doing my first project using MVC in PHP, and I came across this question:

For ajax and requisições assíncronas , when I make a request to a page, this page that processes the ajax request would be the controller

(eg view-ajax controller-php ~ model-php )

Or would I have to make a page that is called by ajax and that page calls the controller?

controller-php ~ > model-help php )

Thank you!

    
asked by anonymous 25.07.2018 / 23:27

1 answer

3

Friend, I'll try to describe it simply and objectively. Your first example is more correct in my opinion.

In the basic MVC standard the controller has the function of being the "face" responsible for acting on a request (route) and possibly relating to models or views to deliver what you requested. He is the controller of actions. Therefore, I see no reason not to directly use the controller.

In my view, it's okay for your view to make the ajax request for a route and that it calls the controller strong> model and respond with this data. At least that's how it works in most frameworks I know.

    
25.07.2018 / 23:56