Files
ClassContent/历届学生/韩想/项目开发/练习项目/ajax练习/赵俊凯/ajax.html
2024-09-27 02:06:13 +08:00

45 lines
1.2 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<ul>
</ul>
</body>
<script src="http://127.0.0.1:3000/api/index" ></script>
<script>
// // 先拿出电话
// var http = new XMLHttpRequest();
// // 输入号码(里面有 GET, POST,PUT,DELETE,OPTION等方法)
// http.open("GET","http://127.0.0.1:3000/api/index");
// // 拨打号码
// http.send()
// //
// http.onreadystatechange = function (){
// if (http.readyState==4)
// {
// if (http.status==200){
// var res = JSON.parse(http.responseText)
// console.log(res)
// res.data.forEach((value, index) =>{
// console.log(value)
// document.querySelector("ul").innerHTML +=`<li>${value.title}</li>`
// })
// }
// else {
// alert("网络不好 ")
// }
// // console.log( http.responseText)
// //将字符串转化为对象
// // console.log(JSON.parse(http.responseText))
// //将对象转化字符串
// // console.log(JSON.stringify(http.responseText))
//
// }
// }
</script>
</html>