Created
November 30, 2014 00:35
-
-
Save ischenkodv/a3b6c5485437f46b6c04 to your computer and use it in GitHub Desktop.
Return JSON data from action of Joomla controller.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* JSON response from controller's action. | |
*/ | |
public function run( ) | |
{ | |
JFactory::getDocument()->setMimeEncoding( 'application/json' ); | |
JResponse::setHeader('Content-Disposition','attachment;filename="progress-report-results.json"'); | |
$data = array( | |
'foo' => 'bar' | |
); | |
echo json_encode( $data ); | |
JFactory::getApplication()->close(); // or jexit(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment