flight\Engine::_jsonp PHP Méthode

_jsonp() public méthode

Sends a JSONP response.
public _jsonp ( mixed $data, string $param = 'jsonp', integer $code = 200, boolean $encode = true, string $charset = 'utf-8', integer $option )
$data mixed JSON data
$param string Query parameter that specifies the callback name.
$code integer HTTP status code
$encode boolean Whether to perform JSON encoding
$charset string Charset
$option integer Bitmask Json constant such as JSON_HEX_QUOT
    public function _jsonp($data, $param = 'jsonp', $code = 200, $encode = true, $charset = 'utf-8', $option = 0)
    {
        $json = $encode ? json_encode($data, $option) : $data;
        $callback = $this->request()->query[$param];
        $this->response()->status($code)->header('Content-Type', 'application/javascript; charset=' . $charset)->write($callback . '(' . $json . ');')->send();
    }