PHP Zend Framework 2.0.2を使用して、AJAX呼び出しの後にJSONデータを返します。明らかに、Internet Explorer 9は、呼び出し元のJavascriptメソッドにデータを返すのではなく、データをダウンロードしたいと考えています。
このような投稿とこれContent-Type: text/plain
はの代わりに使用すると言ってContent-Type: application/json
いますが、ZF2のJsonModelでこれを行うにはどうすればよいですか?初めてです...
setOptions()
配列に何かを設定する必要があると思いますが、何ですか?
public function testJsonAction()
{
$jsonResponse = new JsonModel(array('success' => false));
$jsonResponse->setOptions(array(
// ** Should I put something here? What? **
));
return $jsonResponse;
}
私はこれらを使ってみました:
$this->getResponse()->getHeaders()->addHeaderLine('Content-Type', 'text/plain');
$this->getResponse()->getHeaders()->addHeaderLine('Content-Disposition', 'inline; filename="textdata.json"');
ただし、応答ヘッダーのHTTPContent-Typeは変更されません。
Key Value
Response HTTP/1.1 200 OK
Content-Type application/json
Server Microsoft-IIS/7.5
X-Powered-By PHP/5.3.13
Set-Cookie ZDEDebuggerPresent=php,phtml,php3; path=/
Content-Disposition inline; filename="textdata.json"
X-Powered-By ASP.NET
Date Wed, 10 Oct 2012 13:19:42 GMT
Content-Length 17
ご協力いただきありがとうございます!