• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
is any global way pass session vars to views or THE ONLY WAY IS when pass vars to vie

#1
Code:
  <h2>Welcome Back, <?php echo $this->session->userdata('username'); ?>!</h2>

1    3.1.7
How this session var passed to view and get accessed directly from $this->session obj? is any global way pass session vars to views or THE ONLY WAY IS when pass vars to view from controller like $data below????

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

2   3.1.7
API JSON requests in codeigniter like this https://tech.yandex.com/translate/doc/dg...e-docpage/

in what page of manual exist more info about codeigniter json requests????
Reply

#2
You can load session library in autoload file after that no need for passing the parameter in view file.
You can directly get the session value in view file.
Reply

#3
You can pass variables to a view using.

PHP Code:
$this->load->vars($data); 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#4
(01-31-2018, 06:43 AM)lsepolis123 Wrote: in what page of manual exist more info about codeigniter json requests????

Other than the input class method is_ajax_request() (Docs HERE) there really isn't any.

There isn't much you need to know other than the URL from the JavaScript should point to a controller/method. That controller/method needs to  echo back the kind of data that was defined in the ajax call. If that data is JSON then usually a call to json_encode($data); happens somewhere along the line.

There are lots of examples out in the wild on how to "do" AJAX with CI.

One library that I found very useful is ThingEngineer/Codeigniter-jQuery-Ajax.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.