Skip to content

Commit 140761b

Browse files
author
浪里行舟
authored
Update index.html
1 parent 2715671 commit 140761b

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

多种跨域方式/8.nginx/index.html

+7-12
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,12 @@
88
</head>
99
<body>
1010
<script>
11-
let xhr = new XMLHttpRequest;
12-
xhr.open('get','http://localhost/a.json',true);
13-
xhr.onreadystatechange = function () {
14-
if(xhr.readyState === 4){
15-
if(xhr.status>=200 && xhr.status < 300 || xhr.status ===304){
16-
console.log(xhr.response);
17-
console.log(xhr.getResponseHeader('name'));
18-
}
19-
}
20-
}
21-
xhr.send();
11+
var xhr = new XMLHttpRequest();
12+
// 前端开关:浏览器是否读写cookie
13+
xhr.withCredentials = true;
14+
// 访问nginx中的代理服务器
15+
xhr.open('get', 'http://www.domain1.com:81/?user=admin', true);
16+
xhr.send();
2217
</script>
2318
</body>
24-
</html>
19+
</html>

0 commit comments

Comments
 (0)