Ext.Error: You're trying to decode an invalid JSON String

Hallo, ich habe mir ein kleines Backend-Modul gebastelt das lediglich ein Formular mit einer Combobox enthält. Wenn ich das Formular nun absende bekomme ich folgenden Fehler: [quote] Ext.Error: You’re trying to decode an invalid JSON String: { „success“: true, „message“: „Successfully updated 47 of 100 things“ } [/quote] meine Controller-Action sieht so aus: public function importThingsAction(){ $total = 100; $counter = 47; $response = array( 'success' =\> true, 'message' =\> sprintf("Successfully updated %s of %s things", $counter, $total) ); echo json\_encode($response); return true; } Hier wird also lediglich ein Json-String zurückgegeben. Der kommt ja offensichtlich auch an aber irgendwo kommen noch diese beiden eckigen Klammern her. Mein ExtJs-Code sieht so aus: /\*\* \* @return [Ext.form.Panel] \*/ getMyForm: function() { var me = this; var toolbar = Ext.create('Ext.toolbar.Toolbar', { dock: 'bottom', cls: 'shopware-toolbar', /\* {if {acl\_is\_allowed privilege=import}} \*/ items: ['-\>', { text: me.snippets.start, cls: 'primary', formBind: true, handler: function () { var form = this.up('form').getForm(); if (!form.isValid()) { return; } form.submit({ url: ' {url module=backend controller=MyController action=importThings}', waitMsg: me.snippets.uploading, success: function (fp, o) { Ext.Msg.alert('Result', o.result.message); }, failure: function (fp, o) { Ext.Msg.alert('Fehler', o.result.message); } }); } }] /\* {/if} \*/ }); return Ext.create('Ext.form.Panel', { xtype: 'form', title: me.snippets.titleImport, bodyPadding: 5, layout: 'anchor', dockedItems: toolbar, defaults: { anchor: '100%', labelWidth: 300 }, items: [{ xtype: 'combobox', fieldLabel: me.snippets.data, name: 'type', store: me.getImportComboStore(), emptyText: me.snippets.choose, forceSelection: true, allowBlank: false, editable: false, mode: 'local', triggerAction: 'all', displayField: 'label', valueField: 'id', listeners: { 'change': function (field, newValue) { } } }] }); }, /\*\* \* Creates store object used for the typ column \* \* @return [Ext.data.SimpleStore] \*/ getImportComboStore: function() { var me = this; return new Ext.data.SimpleStore({ fields: ['id', 'label'], data: [['categories', me.snippets.categories], ['articles', me.snippets.articles], ['images', me.snippets.images] ] }); } Hat jemand einen Tipp woran es liegen kann?

Hallo hbee, ich bin mir nicht ganz sicher, aber ich denke nach Befolgung der nächsten zwei Punkte dürfte dies funktionieren: 1. Leitet dein Backend-Controller von “Shopware_Controllers_Backend_ExtJs” ab? 2. Übergeb die Daten per $this->View()->assign($response); und nicht über dein echo. Das return true; dürfte auch überflüssig sein. Hilft dies bereits? Gruß, Patrick :shopware:

1 „Gefällt mir“

[quote=„Patrick Stahl“] 2. Übergeb die Daten per $this->View()->assign($response); und nicht über dein echo. [/quote] Hallo Patrick, vielen Dank das war’s!