<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="js/myAjax.js"></script>
</head>
<body>
<button id="btn">发送请求</button>
<table border="1" cellpadding="0" cellspacing="0" id="table" width="600">
<tr><th>ID</th><th>姓名</th><th>性别</th></tr>
</table>
<script>
/*
json字符串->json对象 JSON.parse(json字符串)
json对象->json字符串 JSON.stringify(json对象)
*/
var str='<tr><th>ID</th><th>姓名</th><th>性别</th></tr>';
document.querySelector('#btn').onclick=function(){
window.myAjax({
type:'get',
url:'student.json',
success: function (res) {
for(var i=0;i<res.length;i++){
str+="<tr><td>"+res[i]['id']+"</td><td>"+res[i]['name']+"</td><td>"+res[i]['sex']+"</td></tr>";
}
table.innerHTML=str;
}
})
}
</script>
</body>
</html>
[
{
"name":"常石磊",
"sex":"男",
"id":"1"
},
{
"name":"金志文",
"sex":"男",
"id":"2"
},
{
"name":"周笔畅",
"sex":"女",
"id":"3"
},
{
"name":"白举纲",
"sex":"男",
"id":"4"
},
{
"name":"白安",
"sex":"女",
"id":"5"
}
]

是代码出问题了吗