# Json string response after ajax call in cakephp 4.4.11

**URL:** <https://discourse.cakephp.org/t/json-string-response-after-ajax-call-in-cakephp-4-4-11/10984>\
**Category:** Uncategorized\
**Created:** [February 26, 2023, 4:42pm UTC](https://discourse.cakephp.org/t/json-string-response-after-ajax-call-in-cakephp-4-4-11/10984 "2023-02-26T16:42:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![YesNo](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/yesno/32/334_2.png) [@YesNo](https://discourse.cakephp.org/u/YesNo)\
**Post date:** [February 26, 2023, 4:42pm UTC](https://discourse.cakephp.org/t/json-string-response-after-ajax-call-in-cakephp-4-4-11/10984/1 "2023-02-26T16:42:14Z")

</div>

Normaly I use this

> $this-\>response-\>getBody()-\>write(json\_encode($array));

from a controller/action,

but is there a better way always to get a json stream back to client???

Thank you for any hint.

Michael

---

<div class="post-metadata">

**Author:** ![KevinPfeifer](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kevinpfeifer/32/3365_2.png) [@KevinPfeifer](https://discourse.cakephp.org/u/KevinPfeifer)\
**Post date:** [February 26, 2023, 6:56pm UTC](https://discourse.cakephp.org/t/json-string-response-after-ajax-call-in-cakephp-4-4-11/10984/2 "2023-02-26T18:56:57Z")

</div>

See [JSON view example from docs gives "Missing Template error" - #4 by KevinPfeifer](https://discourse.cakephp.org/t/json-view-example-from-docs-gives-missing-template-error/10536/4)

---

<div class="post-metadata">

**Author:** ![YesNo](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/yesno/32/334_2.png) [@YesNo](https://discourse.cakephp.org/u/YesNo)\
**Post date:** [April 11, 2023, 12:40pm UTC](https://discourse.cakephp.org/t/json-string-response-after-ajax-call-in-cakephp-4-4-11/10984/3 "2023-04-11T12:40:25Z")

</div>

Thanks a lot for this but this is just a response with pane json string as from ajax request.

I’m still have this problem. ☹  
Michael
