Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

json problem (valums ajax uploader with zend framework)

Tags:

I am using the ajax uploader and the Zend Framework.

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

The problem is that the uploader expects every responste to be "text/html" but the json helper sends "application/json" as mimetype.

With a usual response every thing works fine, but I need to send some information back to the script.

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

like image 473
user63371 Avatar asked Jun 21 '09 21:06

user63371


2 Answers

You can affect the response by using the response object. From within your controller:

$content = Zend_Json::encode(array('Foo' => 'Nice', 'Bar' => 'Vice'));
$this->getResponse()
     ->setHeader('Content-Type', 'text/html')
     ->setBody($content)
     ->sendResponse();
exit();
like image 123
karim79 Avatar answered Oct 12 '22 04:10

karim79


Yet another variant

echo Zend_Json::encode(array('result' => true));
exit;
like image 35
Pavel Avatar answered Oct 12 '22 05:10

Pavel