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

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

Hi,

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.
   
Code:
echo json_encode($this->upload->data());

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

He uses :

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

I use :

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

I also saw somewhere online

Code:
$data = $this->load->view('theview',$data, TRUE);
$this->output->set_output($data);

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
Reply


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