In CakePHP, the framework detects what data type to return in using either the url with the extension .json
OR they search for the Accepts
http header.
In JSONP, I cannot modify the hTTP header. https://stackoverflow.com/a/19604865/80353
I want to avoid using .json
I then tried to set the viewClass using the code below:
if ($this->request->is('ajax')) {
$this->log('enter here');
$this->viewClass = 'Json';
}
Subsequently, I realized that the request will not work because the header does not contain the XMLHTTPRequest.
My questions are:
1) how do I return Json data for jsonp requests without resorting to the extension in the url?
2) is there a way for cakephp to detect a jsonp request? My gut says this is not possible.