如何在页面上的JS读取其他JS文件数组
导入一个其他站点的JS文件,而那个JS文件内容为[{"a":1,"b":2},{"a1":"a1","b1":"b1"}]如果将这个JS文件下载到本地后,修改为vara=...
导入一个其他站点的JS文件,而那个JS文件内容为[{"a":1,"b":2},{"a1":"a1","b1":"b1"}]
如果将这个JS文件下载到本地后,修改为 var a = [{"a":1,"b":2},{"a1":"a1","b1":"b1"}]
页面JS alert(a[0].a);成功输出结果1,但如果直接调用其它站点的话,JS上该如何调用?
如果JS文件内容为var a = [{"a":1,"b":2},{"a1":"a1","b1":"b1"}],可以通过a[0].a调用,
而如果JS文件内容为[{"a":1,"b":2},{"a1":"a1","b1":"b1"}],该如何调用? 展开
如果将这个JS文件下载到本地后,修改为 var a = [{"a":1,"b":2},{"a1":"a1","b1":"b1"}]
页面JS alert(a[0].a);成功输出结果1,但如果直接调用其它站点的话,JS上该如何调用?
如果JS文件内容为var a = [{"a":1,"b":2},{"a1":"a1","b1":"b1"}],可以通过a[0].a调用,
而如果JS文件内容为[{"a":1,"b":2},{"a1":"a1","b1":"b1"}],该如何调用? 展开
1个回答
2016-03-06 · 百度知道合伙人官方认证企业
育知同创教育
1【专注:Python+人工智能|Java大数据|HTML5培训】 2【免费提供名师直播课堂、公开课及视频教程】 3【地址:北京市昌平区三旗百汇物美大卖场2层,微信公众号:yuzhitc】
向TA提问
关注
展开全部
直接用就可以,不如a.js包含
var areaServer=[{"id":"6122","name":"神骑世界","order":"1",
"server":[{"id":"34579","name":"所有区服","order":"0","value":"0"}],
"value":"1"},{"id":"6613","name":"狼烟","order":"桥森消1",
"server":[{"id":"37952","name":"烽火万里","order":"0","value":"1001"}],"value":"2"}];
再b.htm页面,需要先引用js文件,相对路径绝对路径都春羡可以,但是必须是网络路径,而不是敏知本地路径
<script type="text/javascript" src="a.js"></script>
<script type="text/javascript">
alert(areaServer[0].id);
</script>
var areaServer=[{"id":"6122","name":"神骑世界","order":"1",
"server":[{"id":"34579","name":"所有区服","order":"0","value":"0"}],
"value":"1"},{"id":"6613","name":"狼烟","order":"桥森消1",
"server":[{"id":"37952","name":"烽火万里","order":"0","value":"1001"}],"value":"2"}];
再b.htm页面,需要先引用js文件,相对路径绝对路径都春羡可以,但是必须是网络路径,而不是敏知本地路径
<script type="text/javascript" src="a.js"></script>
<script type="text/javascript">
alert(areaServer[0].id);
</script>
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询