Rendering HTML with AJAX call using PHP and MVC concept

Asked

Viewed 234 times

0

Good night.

I usually use the MVC (Model-View-Controller) standard in projects, independent of the programming language.

In PHP the directory structure looks like this:

- assets
    - css
    - js
    - img
    - font
- model
- controller
- view
- session
- database
  index.php

The question I have is how much in an AJAX call passing data to a PHP file and returning only database results using the parameters passed by the AJAX call as input.

Following the MVC model we can build the HTML directly in the controller or it would be safer to return only the values and have the HTML be rendered on the page using Javascript but leaving the client side to render the HTML on the page which can leave the side of the slow client.

If you know not only these two solutions, but others of receiving an HTML and render using the concept of MVC on a given page also accepted, what we want is to learn more about this subject.

  • 3

    The controller can use a view to format HTML, how to pass JSON type data to Javascript to render. But the controller does not format any HTML, this is the role of view.

  • 1

    About leaving lado do cliente lento, recommend this question about Use JS to relieve PHP.

  • 1

    Thanks for the answers.

  • It was not a direction as I would like to give, it became somewhat theoretical, but I was not sure if your doubt is about the Pattern or the implementation. Send the formatted HTML or format it with Javascript, I think this in the question I mentioned. You can further detail your question if you need.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.