Welcome Guest, Not a member yet? Register   Sign In
How to load json file in codeigniter… newbie
#1

[eluser]danny_ci[/eluser]
Hi, everyone…
I want to ask something about how to load json file in codeigniter
But before load the json file, i want to pass some data to json file
Any idea for this??

Thanks before

Here is some code to load json file in jquery event calendar

Code:
$("#calendar").eventCalendar({
  eventsjson: 'file.json' //here to load json file
});
#2

[eluser]NeoArc[/eluser]
Code:
$data = json_decode(file_get_contents('file.json'));
var_dump($data);
#3

[eluser]Ajaxboy[/eluser]
If you use Cjax (http://ellislab.com/forums/viewthread/229077/), can do this to pass data:

Code:
$("#calendar").eventCalendar({
  eventsjson: 'ajax.php?calendar/json/var1/var2'
});



Code:
Class Calendar Extends CI_Controller {

  function json($var1, $var2)
  {
    $data = array();
    
    $data['var1' = $var1;
    $data['var2'] = $var2;
    
    $data['other_data'] = 'some data';

    return $data; //return a json formatted object
  }

}




Theme © iAndrew 2016 - Forum software by © MyBB