# Ajax Suche mit JSON Response

**URL:** <https://forum.shopware.com/t/ajax-suche-mit-json-response/50563>\
**Category:** Programmierung\
**Created:** [20. Januar 2018 um 23:15 UTC](https://forum.shopware.com/t/ajax-suche-mit-json-response/50563 "2018-01-20T23:15:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![brettvormkopp](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/brettvormkopp/32/7788_2.png) [@brettvormkopp](https://forum.shopware.com/u/brettvormkopp)\
**Post date:** [20. Januar 2018 um 23:15 UTC](https://forum.shopware.com/t/ajax-suche-mit-json-response/50563/1 "2018-01-20T23:15:50Z")

</div>

Hallo,  
ich baue gerade Theme mit Bootstrap4 . Die Ajax-Suche funktioniert auch, aber es wird ein HTML-Block als Response ausgegeben? Wie kann ich mir ein JSON&nbsp;zurückgeben lassen?&nbsp;Habe da nix gefunden unter [shopware/Search.php at 5.3 · shopware/shopware · GitHub](https://github.com/shopware/shopware/blob/5.3/engine/Shopware/Controllers/Frontend/Search.php) Danke und Gruss.

PS: Wäre auch cool wenn man an die Ajax-Suche einen richtigen Body mit mehreren Parametern schicken könnte, statt ein request auf url+suchwort

---

<div class="post-metadata">

**Author:** ![brettvormkopp](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/brettvormkopp/32/7788_2.png) [@brettvormkopp](https://forum.shopware.com/u/brettvormkopp)\
**Post date:** [21. Januar 2018 um 00:20 UTC](https://forum.shopware.com/t/ajax-suche-mit-json-response/50563/2 "2018-01-21T00:20:32Z")

</div>

Hab den falschen Controller angegeben. Das hier müsste es sein&nbsp;[shopware/AjaxSearch.php at 5.3 · shopware/shopware · GitHub](https://github.com/shopware/shopware/blob/5.3/engine/Shopware/Controllers/Frontend/AjaxSearch.php)&nbsp;

Verständnisfrage: Mit dem Ajax-Request wird der Controller AjaxSearch.php angesprochen. Der Controller holt die Variablen&nbsp;ab und gibt sie an&nbsp;frontend/search/ajax.tpl. Dort werden diese Variablen dann gerendert? Das Result geht dann zurück/success ?

Das müsste dann bedeuten, wenn ich die frontend/search/ajax.tpl zu einem json\_encode® mache wird ein json-object zurückgegeben?

---

<div class="post-metadata">

**Author:** ![brettvormkopp](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/brettvormkopp/32/7788_2.png) [@brettvormkopp](https://forum.shopware.com/u/brettvormkopp)\
**Post date:** [21. Januar 2018 um 00:57 UTC](https://forum.shopware.com/t/ajax-suche-mit-json-response/50563/3 "2018-01-21T00:57:11Z")

</div>

ich geb mir mal selbst die Antwort:&nbsp;frontend/search/ajax.tpl die Results mit json\_encode formen.
