Add JSONP as a default response.
This commit is contained in:
parent
f25d09dd07
commit
1beea5d594
|
@ -98,6 +98,26 @@ public static function json($data, $status = 200, $headers = array())
|
||||||
return new static(json_encode($data), $status, $headers);
|
return new static(json_encode($data), $status, $headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new JSONP response.
|
||||||
|
*
|
||||||
|
* <code>
|
||||||
|
* // Create a response instance with JSONP
|
||||||
|
* return Response::jsonp($data, 200, array('header' => 'value'));
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
|
* @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.
|
* Create a new response of JSON'd Eloquent models.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue