Iは、以下のテンプレートを有する:[DOM-繰り返し:: DOMリピート]: `items`の予想される配列、見つかったオブジェクト
<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]]">
AJAX応答は、以下のJSON(修正)を含む:
を{
"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
}]
}
しかし、私はエラーを取得する:
[dom-repeat::dom-repeat]
: expected array foritems
, foundObject {1: Array[1], 2: Array[2], 3: Array[1]}
なぜ? ありがとう!
エラーメッセージが正しい - "ルートオブジェクトは、"(すなわち '[] 'によってラップ)配列が、オブジェクト(' {} 'によってラップ) – ain
しかし、他のではありません同様のサービス応答が{}でラップされて動作しています – Jaime
@Jaime私はあなたの新しい[tag:php]質問にPHPコードを移動しました。 – tony19