first commit

This commit is contained in:
编码猿
2024-09-27 02:06:13 +08:00
commit 852d94fbb9
36760 changed files with 3274413 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
<!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>
<script>
// function getData (res) {
// console.log(res)
// }
var http = new XMLHttpRequest()
http.open("GET","http://127.0.0.1/index.php")
http.send()
http.onreadystatechange = function () {
if(http.readyState == 4){
console.log(JSON.parse(http.responseText))
}
}
// 跨域 Access-Control-Allow-Origin
// 谁导致的? 浏览器
// 原因:浏览器有个同源策略
// 作用保护后端的api数据安全
// 当前页面的访问地址和你ajax需要访问的地址是否完全一致
// 1: 端口是否一致
// 2: 协议是否完全一致
// 3: 域名是否一致
// a https://www.a.com b http://www.a.com
// 跨域解决方案
// 1: 后端设置cros允许前端跨域
// 2: jsonp
// 它不是ajax请求只是一个普通的js文件资源请求浏览器不会拦截文件请求然后用过 callback 方式回调数据
// 3: 后端代理(nginx)
// A 前端 --> C 后端(别人)
// A 前端 ---> B 后端(自己) cors
// B 后端 ---> C 后端(别人)
// C ---> B ---> A
</script>
<!-- <script src="http://127.0.0.1/index.php?cb=getData"></script> -->
</body>
</html>

View File

@@ -0,0 +1,38 @@
<!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>tabs</title>
<style>
.on {
color: red;
}
</style>
</head>
<body>
<ul>
<li class="on">苏世博会</li>
<li>呜呜呜呜</li>
<li>www</li>
</ul>
<script>
document.querySelectorAll("ul li").forEach(val => {
val.onclick = function() {
document.querySelectorAll("ul li").forEach(vals => vals.className = "" )
val.className = "on"
}
})
</script>
</body>
</html>