test.txt的json数据如下
[
{"XH":1,"YWName":"业务1","SName":"系统1","QDName":"渠道1","HJNumber":5},
{"XH":2,"YWName":"业务2","SName":"系统2","QDName":"渠道2","HJNumber":6},
{"XH":3,"YWName":"业务3","SName":"系统3","QDName":"渠道3","HJNumber":7}
]
jquery ajax读取json数据的方式
$.getJSON('test.txt',function(data){
}
表格:
<script>
$(document).ready(function(){
var data = [
{"XH":1,"YWName":"业务1","SName":"系统1","QDName":"渠道1","HJNumber":5},
{"XH":2,"YWName":"业务2","SName":"系统2","QDName":"渠道2","HJNumber":6},
{"XH":3,"YWName":"业务3","SName":"系统3","QDName":"渠道3","HJNumber":7}
];
var $table=$('<table border="1"></table>');
var $head =$('<tr><td>序号</td><td>业务名称</td><td>系统名称</td><td>渠道名称</td><td>环节数</td><td>操作</td></tr>');
$table.append($head);
for(var i=0;i<data.length;i++){
var row = data[i];
var $tr = $('<tr></tr>');
var XH= $('<td>'+row['XH'] + '</td>');
var YWName= $('<td>'+row['YWName'] + '</td>');
var SName= $('<td>'+row['SName'] + '</td>');
var QDName= $('<td>'+row['QDName'] + '</td>');
var HJNumber= $('<td>'+row['HJNumber'] + '</td>');
$tr.append(XH).append(YWName).append(SName).append(QDName).append(HJNumber).append('<td></td>');
$table.append($tr);
}
$('body').append($table);
});
</script>
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。