Skip to content

Instantly share code, notes, and snippets.

@jayarjo
Created October 27, 2014 07:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jayarjo/27e61105ba917eb3816a to your computer and use it in GitHub Desktop.
Save jayarjo/27e61105ba917eb3816a to your computer and use it in GitHub Desktop.
$callback = $_REQUEST['callback'];
// Create the output object.
$output = array('a' => 'Apple', 'b' => 'Banana');
//start output
if ($callback) {
header('Content-Type: text/javascript');
echo $callback . '(' . json_encode($output) . ');';
} else {
header('Content-Type: application/x-json');
echo json_encode($output);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment