<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> </head> <body> <div id="search">123</div> <img id="img" src=''/> </body> <script> var data = 'https://www.renrenche.com/api/qrcode/app?fr=bd_pz&platform=PC&plog_id=cb16219f6770b3c0595119a854f4f84c' document.getElementById("search").onclick = function() { var request = null; try{ request = new XMLHttpRequest(); } catch(e){ request = new ActiveXObject('Microsoft.XMLHTTP'); } request.open("GET", data); //发送请求并带入参数,返回后给出判断后的结果,也就是是否右这个员工 request.onreadystatechange = function() { if (request.readyState===4) { if (request.status===200) { var gg = JSON.parse(request.responseText); console.log(typeof gg ) console.log(gg.status) console.log(gg.data.m_yl_1.qr) document.getElementById('img').setAttribute('src',gg.data.m_yl_1.qr) } else { alert("发生错误:" + request.status); } } } request.send(); } </script> </html>