我有以下的JSON文件:的getJSON()jQuery的下拉菜單無法正常工作
{
"viewport_size":
{"display_name":"VIEWPORT SIZE:",
"name":"viewport_size",
"format":"number",
"type":"dropdown",
"dflt":"640 * 480",
"values":["800*600","1280*720","1920*1080"],
"isMandatory":"true"},
"framerate":
{"display_name":"FRAMERATE:",
"name":"fps",
"format":"number",
"type":"dropdown",
"dflt":"30",
"values":["45","60","90"],
"isMandatory":"true"},
"pattern_resolution":
{ "display_name":"PATTERN RESOLUTION:",
"name":"resoln",
"format":"number",
"type":"dropdown",
"dflt":"8",
"values":["16","32","64"],
"isMandatory":"true"}
}
我試着來填充我的js文件中使用的getJSON()下拉列表
var INPUT_TEXT='<input type="text"/>';
var INPUT_RADIO='<input type="radio"/>';
var INPUT_CHECKBOX='<input type="checkbox"/>';
var INPUT_DROPDOWN='<select id="items"></select>';
var SUBMIT_BUTTON='<input type="button" value="SUBMIT"/>';
var NEWLINE='<br></br>';
$.getJSON('json_input/client_settings_input.json',function(clientData)
{
$.each(clientData,function(i,feild)
{
if(this.type=="dropdown")
{
var html = '';
var len = feild.values.length;
//alert('lenght is'+len);
for (var i = 0; i< len; i++){
//alert('inside for');
html += '<option>'+ feild.values[i]+'</option>';
}
$('body #tabs #tabs-2 client').append (this.display_name).append(INPUT_DROPDOWN).append(html).append(NEWLINE);
}
});
$('body #tabs #tabs-2 #client').append(SUBMIT_BUTTON);
});
但我無法查看下拉列表和值...請指出我要出錯的地方..
我想像這樣填充VIEWPORT:dropdownlist values FRAMERATE:dropdownlist值 PATTERN_RESOLUTION:下拉列表值