Welcome Guest, Not a member yet? Register   Sign In
How create a JavaScript file with a view in CodeIgniter?
#9

[eluser]davidbehler[/eluser]
Lets say you have a controller called "js" and a function "get"
Code:
class js extends Controller
{
   function js()
   {
      parent::Controller();
   }

   function get($id = 0)
   {
      $data = array();
      $data['test'] = $this->Test_model->get_test($id);
      $this->output->set_header("Content-type: text/javascript");
      $this->load->view('js_file_view', $data);
   }
}

Now you can include the file using
Code:
[script type='text/javascript” src=”<?=site_url('js/get/123');?>”][/script]


Messages In This Thread
How create a JavaScript file with a view in CodeIgniter? - by El Forum - 07-20-2009, 10:33 AM



Theme © iAndrew 2016 - Forum software by © MyBB