欲這個JSON加載到selectize:負載多維JSON陣列的物體插到selectize.js
{"platforms":
[{"id":32,"name":"Sega Saturn","slug":"saturn"},
{"id":14,"name":"Mac","slug":"mac"},
{"id":47,"name":"Virtual Console (Nintendo)","slug":"vc"},
{"id":34,"name":"Android","slug":"android"},
{"id":84,"name":"SG-1000","slug":"sg1000"},
{"id":58,"name":"Super Famicom","slug":"sfam"},
{"id":82,"name":"Web browser","slug":"browser"}]
}
我想它操作非常類似於this example provided by the Selectize.js developers(不包括在各URL部分),除了明顯而不是使用我的json數據預先製作的ID和名稱。
任何幫助表示讚賞。
代碼我目前正在嘗試使用:
options: [
for (var i = 0; i < platforms.platforms.length; i++)
{
var counter = platforms.platforms[i];
{id: counter.id, title: counter.name},
console.log(counter.name);
}
下面介紹一下JSON看起來在控制檯登錄時它像:
編輯:This is another example that I'm looking at as it uses JSON.
什麼是你的問題? – klenium
我在解析特定的JSON到selectize選擇框時遇到問題。我想以此爲例。 – AllTheGoodNamesWereTaken
你是什麼意思?你有什麼「麻煩」?你有什麼嘗試使用?什麼是錯誤信息?圖像中出現了什麼問題?它看起來應該如此。 – klenium