var xhr=new XMLHttpRequest();
xhr.open(‘GET’,‘b.txt’,true)
xhr.send();
console.log(‘a’)
xhr.onreadystatechange=function(){
if(xhr.readyState4){
console.log(‘a’)
if(xhr.status200){
console.log(typeof xhr.responseText)
showlist(xhr.responseText)
}
}
}
var str=’’;
function showlist(data){
var value=JSON.parse(data)
console.log(typeof value)
value.forEach(function(item,index){
//str+=’
- ’+item.name+’-----’+index+’-----’+item.age+’
- ’
str+=’ - ’+item.name+’
- ’
}) ul.innerHTML=str }