追加到表格.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<table width="500" border="1">
<tr>
<th>姓名
<th>年龄
<th>性别
</tr>
</table>
<button>点击
<script src="ajax3.0-min.js">
<script>
// 需求:当点击button按钮的时候,获取服务器的数据,并追击到table表格中
// 1.获取table表格
var table = document.getElementsByTagName('table')[0];
var btn = document.getElementsByTagName('button')[0];
// 2.点击事件
btn.onclick = function() {
// ajax获取数据:是一个对象,需要在Ajax()函数传递"JSON"的参数,约束了msg是对象类型的数据
Ajax('JSON').get('2.json', function(msg