Answer the question
In order to leave comments, you need to log in
Is it possible to return JSON with an array in the response, which will contain HTML elements from views?
The page is first loaded by the server, and later (filters or switching pagination) it switches to AJAX.
Accordingly, when components are rendered in the first case, we can directly access the methods specified in the model in the template and successfully extract as much information as we like.
For an AJAX request, we can immediately get all the necessary "chains" of data, but then the nesting of the object grows and rendering such a component in JS is extremely inconvenient.
Is it possible to access the view in the controller and render the HTML of the components, and then pass them back in the form of a JSON object?
The answer is needed in JSON , because there and the status, and the text, and other necessary data.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question