Hi Not sure on the best way to do this. I have some javascript that requires a json formatted file to populate a calendar. I can do this in php by adding the following to the file that is being requested:
header('Access-Control-Allow-Origin: *');
$array = array(
array('date' => "27/9/2015", 'title' => 'BBC Event', 'link' => 'http://www.bbc.co.uk')
);
echo json_encode($array);
I need to be able to do the same with craft. I have tried just formatting the entries in twig which returns the json as it should be but because the header is missing the javascript call does not run it. I have also created a small plugin to pull out all the entries which may be a better option. I just need to know how to return those entries in json to a template as per the above php would create with a header included.
Any help much appreciated.
Cheers