企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持知识库和私有化部署方案 广告
~~~ <script> /* 1.创建ajax核心对象 2.与服务器建立连接 3.向服务器发送请求 4.服务器响应 */ var url= "https://www.easy-mock.com/mock/5bad81fca1b7f6239a61664d/dataTest/pcTest"; var xhr = new XMLHttpRequest(); xhr.open("get",url); xhr.send(); xhr.onreadystatechange = function(){ if(xhr.readyState == 4 && xhr.status == 200){ var reponse = xhr.responseText; console.log(reponse); // JSON.parse 可以将字符串转为JSON对象 var name = JSON.parse(reponse).data.name; console.log(name); } } </script> ~~~