From 660fade34f02b4e9f4e50f70cf19b30fb4968b72 Mon Sep 17 00:00:00 2001 From: shoully Date: Sat, 20 Dec 2014 06:50:48 -0800 Subject: [PATCH] Created 14 JSON (markdown) --- 14-JSON.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 14-JSON.md diff --git a/14-JSON.md b/14-JSON.md new file mode 100644 index 0000000..77d2c28 --- /dev/null +++ b/14-JSON.md @@ -0,0 +1,13 @@ +Flight provides support for sending JSON and JSONP responses. To send a JSON response you pass some data to be JSON encoded: + + Flight::json(array('id' => 123)); + +For JSONP requests you would use the jsonp method. You can optionally pass in the query parameter name you are using to define your callback function: + + Flight::jsonp(array('id' => 123), 'q'); + +So, when making a GET request using ?q=my_func, you should receive the output: + + my_func({"id":123}); + +If you don't pass in a query parameter name it will default to **jsonp**. \ No newline at end of file