Welcome Guest, Not a member yet? Register   Sign In
How do I replace front-end views with JSONs in Codeigniter 3?
#5

(This post was last modified: 08-20-2019, 09:57 PM by Ajax30.)

(08-20-2019, 11:21 AM)ciadmin Wrote: What about something like https://www.codeigniter.com/user_guide/l...ntent_type

Instead of loading any view at all, each controller method would build its "view data" as $data, and then
$this->output->set_content_type('application/json')->set_output(json_encode($data));

How would that code look exactly, in the context of my Posts controller? For the index() method, for instance.
Reply


Messages In This Thread
RE: How do I replace front-end views with JSONs in Codeigniter 3? - by Ajax30 - 08-20-2019, 09:54 PM



Theme © iAndrew 2016 - Forum software by © MyBB