我的 json 响应是这样的(根据萤火虫)
[
{
"value": 1,
"text": "Bill_Process_1",
"selected": false,
"imageSrc": "image.jpg",
"description": "Bill_Process_1"
},
{
"value": 2,
"text": "Bill_Process_2",
"selected": false,
"imageSrc": "image.jpg",
"description": "Bill_Process_2"
},
{
"value": 3,
"text": "Bill_Process_3",
"selected": false,
"imageSrc": "image.jpg",
"description": "Bill_Process_3"
},
{
"value": 4,
"text": "Bill_Process_4",
"selected": false,
"imageSrc": "image.jpg",
"description": "Bill_Process_4"
},
{
"value": 5,
"text": "Bill_Process_5",
"selected": false,
"imageSrc": "image.jpg",
"description": "Bill_Process_5"
}
]
请帮我完成这段代码。它只显示空的下拉菜单。我对如何将它渲染到这里感到困惑..
<div id="myDropdown"></div>
<script type="text/javascript">
var jsonurl = 'dropDown.html';
$.ajax({
type: 'GET',
url: jsonurl,
data: {},
success:function(data){
var options = $("#myDropdown");
$.each(data, function () {
alert(data);
options.append($("<option />").val(this.value).text(this.text));
});
},
error:function(){
}
});
$('#myDropdown').ddslick({
data : jsonurl,
width : 300,
selectText : "Select the bill process",
imagePosition : "right",
onSelected : function(selectedData) {
//callback function: do something with selectedData;
}
});
</script>
我使用 spring @ResponseBody 返回这个 json 数组。
我使用 ddslick 作为我的下拉菜单。这里显示它是
现在我的输出是这样的。它不是以下拉列表的形式加载到 div 的数据,在网页上它一一显示为列表