Skip to content

Instantly share code, notes, and snippets.

@samcroft
Created May 6, 2016 10:35
Show Gist options
  • Save samcroft/aa9e302e4b5bb9ee4586994f799b10a6 to your computer and use it in GitHub Desktop.
Save samcroft/aa9e302e4b5bb9ee4586994f799b10a6 to your computer and use it in GitHub Desktop.
<?php
header('Content-Type: application/json');
$callback = isset($_GET['callback']) ? $_GET['callback'] : false;
$output = array(
'some' => 'data'
);
$output = json_encode($output);
if ($callback) {
echo sprintf('%s(%s)', $callback, $output);
} else {
echo $output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment