JSON Responses
The json method will automatically set the Content-Type header to application/json, as well as convert the given array into JSON using the json_encode PHP function:
If you would like to create a JSONP response, you may use the json method in addition to setCallback: