标签:bsp parse span hang xxx dom read color listener
mybutton.addEventListener(‘click‘, (e) => { let request = new XMLHttpRequest() request.onreadystatechange = () => { if(request.readyState === 4) { console.log(‘请求完毕‘) if(request.status >= 200 & request.status <= 300) { console.log(‘请求成功‘) console.log(request.responseText) //解析xml //let parser = new DOMParser(); //let xmlDoc = parser.parseFromString(request.responseText, "text/xml") //let body=xmlDoc.getElementsByTagName(‘body‘)[0].textContent //console.log(body) //解析json 服务器返回的是字符串 let string = request.responseText let obj = window.JSON.parse(string) console.log(obj) console.log(obj.note) console.log(obj.note.to) } else if(request.status >= 400) { console.log(‘请求失败‘) } } } request.open(‘GET‘, ‘/xxx‘) request.send() })
标签:bsp parse span hang xxx dom read color listener
原文地址:https://www.cnblogs.com/ronyjay/p/9189687.html