Json problem (valums ajax uploader with zend frame)

I am using ajax uploader and Zend Framework.

The problem is that I am using json response for onSubmit. With $this->getHelper('Json')->sendJson($data); I only get saveas dialog.

The problem is that the loader expects each reponste to be "text / html", but the json helper will send "application / json" as a mimetype.

With the usual answer, everything works fine, but I need to send some information back to the script.

So, how can I tell Zend that it should send jsondata with the mimetype type "text / html"?

+4
source share
2 answers

You can influence the response using the response object . From your controller:

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

Another option

 echo Zend_Json::encode(array('result' => true)); exit; 
+1
source

Source: https://habr.com/ru/post/1286548/


All Articles