Tone87 Posted August 30, 2018 Share Posted August 30, 2018 hi, i need to catch a json from ajax call with an hook before output, edit the json and return json edited for a translation service. i tried to set return but not works in output, the output it's the same at original.. how i can return the content to output ? this is an example: public function hookActionAjaxDieOrderControllerdisplayAjaxAddressFormBefore($params) { $jsonOriginal = $params['value'] ; $jsonEdited = $this->prepareForTranslate($jsonOriginal); // return to page json edited $params['value'] = $jsonEdited; return $params; } public function prepareForTranslate($json) { $array= json_decode($json); $output = array(); foreach($array as $key => $data) { $output[$key] = $data; $output['gt_translate_keys'][] = $key; $output['gt_translate_keys'][] = array('key'=>$key,'format' =>'html'); } $jsonEdited = json_encode($output); return $jsonEdited } } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now