码迷,mamicode.com
首页 > Web开发 > 详细

JSON

时间:2018-12-13 21:45:09      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:nload   ali   http   name   func   post   document   body   selector   

 

gun.json文件代码:

{
"Gun_class":[
"栓动式狙击枪",
"射手步枪",
"突击步枪",
"冲锋枪"
],
"Bolt-on-sniper-rifle":[
{
"name":"AWM",
"box_magazine":"10",
"bullet":".300马格南步枪弹",
"caliber":"7.62mm",
"weight":"6.5kg (不含弹匣)"
},
{
"name":"M24",
"box_magazine":"5",
"bullet":"M118特种弹",
"caliber":"7.62mm",
"weight":"5.4kg(不带瞄准镜)"
},
{
"name":"Kar98",
"box_magazine":"5",
"bullet":"7.92×57mm步枪弹",
"caliber":"7.92mm",
"weight":"3.9kg (无弹药装填)"
}
],
"sniper-rifle":[
{
"name":"MINI14",
"box_magazine":"5,20,30",
"bullet":"M193式5.56×45,mm和SS109式5.56×45,mm枪弹",
"caliber":"5.56mm",
"weight":"全枪质量(不含弹匣)----2.9kg"
},
{
"name":"SKS",
"box_magazine":"10",
"bullet":" 7.62×39mm",
"caliber":"7.62mm",
"weight":"未知"
},
{
"name":"SLR",
"box_magazine":"30",
"bullet":"SS109式5.56×45,mm枪弹",
"caliber":"5.56mm",
"weight":"步兵型----4.325kg"
},
{
"name":"MK14",
"box_magazine":"20",
"bullet":"7.62mm",
"caliber":"7.62mm",
"weight":"5.1kg"
}
]

}
gun.js文件代码片段
var header = document.querySelector(‘header‘);
var section = document.querySelector(‘section‘);
var requestURL = ‘https://raw.githubusercontent.com/wusifan19980908/cdu.edu/master/gun.json‘;
var request = new XMLHttpRequest();
request.open(‘GET‘, requestURL);
request.responseType = ‘json‘;
request.send();
var Guns ;
request.onload = function () {
Guns = request.response;
setHeader();
setGuns();
}
远端json代码:https://github.com/wusifan19980908/cdu.edu/blob/master/gun.json

JSON

标签:nload   ali   http   name   func   post   document   body   selector   

原文地址:https://www.cnblogs.com/dedao97/p/10116499.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!