$.ajax({
type: 'POST',
url:'/你的json文件路径/json.txt',
data: {'id':rcid},
dataType:'json',
beforeSend:function(){
//$(".askContentList").append("<li id='loading'>loading...</li>")
},
success:function(json){
alert(json)//取到的json值
},
error:function(){
alert('数据加载失败,请刷新页面!')//消息提醒
}
})
遍历json数组,循环插入option到select中。<select id="select1"></select>
<script src="
<script type="text/javascript">
var jsonData = { 'blogs': ['dudu', 'Artech', 'Fish Li'] }
$.each(jsonData.blogs, function (index, val) {
$("#select1").append("<option value='" + index + "'>" + val + "</option>")
})
</script>
生成的html
<select id="select1">
<option value="0">dudu</option>
<option value="1">Artech</option>
<option value="2">Fish Li</option>
</select>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)