Ich habe die folgende Vorlage:[dom-repeat :: dom-Wiederholung]: erwartetes Array für `Elemente`, gefunden Objekt
<iron-ajax
id="ajax"
url="backend/api.php?operacion=contenidos&idf=[[datos.id]]&len=[[len]]"
handle-as="json"
verbose=true
last-response={{ajaxResponse}}
loading="{{cargando}}"> </iron-ajax>
<template is="dom-repeat" items="[[ajaxResponse]]">
Die AJAX-Antwort enthält die folgende JSON (korrekt):
{
"1": [{
"id": "6",
"idfolleto": "1",
"fila": "1",
"orden": "1",
"tipo": "carrousel",
"titulo": "",
"subtitulo": null,
"color1": null,
"color2": null,
"color_fondo": null
}],
"2": [{
"id": "7",
"idfolleto": "1",
"fila": "2",
"orden": "1",
"tipo": "texto-imagenes",
"titulo": "Texto 1",
"subtitulo": null,
"color1": null,
"color2": null,
"color_fondo": null
}, {
"id": "8",
"idfolleto": "1",
"fila": "2",
"orden": "2",
"tipo": "texto-imagenes",
"titulo": "Texto 2",
"subtitulo": null,
"color1": null,
"color2": null,
"color_fondo": null
}],
"3": [{
"id": "9",
"idfolleto": "1",
"fila": "3",
"orden": "3",
"tipo": "texto-imagenes",
"titulo": "Texto 3",
"subtitulo": null,
"color1": null,
"color2": null,
"color_fondo": null
}]
}
Aber ich erhalte eine Fehlermeldung:
[dom-repeat::dom-repeat]
: expected array foritems
, foundObject {1: Array[1], 2: Array[2], 3: Array[1]}
Warum? Danke!
Die Fehlermeldung ist korrekt - das "Stammobjekt" nicht Array (dh eingewickelt durch '[]'), aber Objekt (eingewickelt durch '{}') – ain
Aber auch andere ähnliche Service-Antwort mit ähnlichem Objekt, eingepackt von {} und es funktioniert – Jaime
@Jaime Ich habe Ihren PHP-Code in Ihre neue [tag: php] Frage verschoben. – tony19