Question

J'utilise le téléchargeur ajax . et le Zend Framework.

Le problème, c’est que j’utilise la réponse json pour onSubmit. Avec $ this- > getHelper ('Json') - > sendJson ($ data); Je ne reçois qu'un dialogue saveas.

Le problème est que le téléchargeur s'attend à ce que chaque réponse soit "text / html". mais l’aide json envoie " application / json " comme type MIME.

Avec une réponse habituelle, tout fonctionne correctement, mais je dois renvoyer des informations au script.

Alors, comment puis-je dire à Zend qu'il doit envoyer jsondata avec le type mime "text / html"?

Était-ce utile?

La solution

Vous pouvez affecter la réponse en utilisant l’objet en réponse . Depuis votre contrôleur:

$content = Zend_Json::encode(array('Foo' => 'Nice', 'Bar' => 'Vice'));
$this->getResponse()
     ->setHeader('Content-Type', 'text/html')
     ->setBody($content)
     ->sendResponse();
exit();

Autres conseils

Encore une autre variante

echo Zend_Json::encode(array('result' => true));
exit;
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top