Sunday, February 8, 2015

Magento – Returning JSON (for AJAX and API Calls) Response From Controller Action

Within your Magento Controller > Action you can use the below code to send a JSON response.

$this->getResponse()->setHeader('Content-type', 'application/json');
$this->getResponse()->setBody($jsonData);

http://www.kathirvel.com/magento-returning-json-for-ajax-and-api-calls-response-from-controller-action/

No comments: