Passing JSON data in codeigniter-Collection of common programming errors
Greetings I have this statement that takes my array of results and echo’s it out to display on my AJAX form using json_encode, however now I want to pass the array as $data over to my Templatebuilder function since i’ll be using the search as part of a bigger template. This is the error i’m getting, for my ajax search. Undefined Variable: Results in ajax_search.php
This is all done within one controller.
if ( $this->input-> is_ajax_request())
{
$this->output->set_header("Cache-Control: no-cache, must-revalidate");
$this->output->set_header("Expires:Mon, 4 Apr 1994 04:44:44 GMT");
$this->output->set_header("Content-type:application/json");
echo json_encode($results);
}
Then I wish to send the data to my templatebuilder with this statement:
echo $this->Templatebuilder('master', $data);
this is my templatebuilder function
private function Templatebuilder ($view, $data) {
$master_data['page1'] = $this->load->view('page1', $data, true);
$master_data['ajax_search'] = $this->load->view('ajax_search', $data, true);
return $this->load->view('master', $master_data, true);
and finally my ajax_search page
–
–
–