Welcome Guest, Not a member yet? Register   Sign In
How to return a view to an ajax call ?

(This post was last modified: 02-26-2015, 12:51 AM by Tao Pai Pai.)


I recently had to modify some code of my colleague. I saw that we don't handle ajax calls the same way.
When it's about returning data, we both use.
echo json_encode($this->upload->data());

However, when we have to return a whole view, we are a bit different :

He uses :

echo $this->load->view('theview',$data);

I use :

$view = $this->load->view('theview',$data, TRUE);
echo $view;

I also saw somewhere online

$data = $this->load->view('theview',$data, TRUE);

Those techniques seem to work correctly, but what the best pratices say about that ? Is one of them safer, faster or more "MVC friendly" ?

Thanks Blush

Messages In This Thread
How to return a view to an ajax call ? - by Tao Pai Pai - 02-25-2015, 01:32 PM

Theme © iAndrew 2016 - Forum software by © MyBB