diff --git a/laravel/response.php b/laravel/response.php index ccd53e1f..51ee33d6 100644 --- a/laravel/response.php +++ b/laravel/response.php @@ -98,6 +98,26 @@ public static function json($data, $status = 200, $headers = array()) return new static(json_encode($data), $status, $headers); } + /** + * Create a new JSONP response. + * + * + * // Create a response instance with JSONP + * return Response::jsonp($data, 200, array('header' => 'value')); + * + * + * @param mixed $data + * @param int $status + * @param array $headers + * @return Response + */ + public static function jsonp($data, $status = 200, $headers = array()) + { + $headers['Content-Type'] = 'application/javascript; charset=utf-8'; + + return new static(json_encode($data), $status, $headers); + } + /** * Create a new response of JSON'd Eloquent models. * @@ -344,4 +364,4 @@ public function __toString() return $this->render(); } -} \ No newline at end of file +}