We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2715671 commit 140761bCopy full SHA for 140761b
多种跨域方式/8.nginx/index.html
@@ -8,17 +8,12 @@
8
</head>
9
<body>
10
<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();
+ var xhr = new XMLHttpRequest();
+ // 前端开关:浏览器是否读写cookie
+ xhr.withCredentials = true;
+ // 访问nginx中的代理服务器
+ xhr.open('get', 'http://www.domain1.com:81/?user=admin', true);
+ xhr.send();
22
</script>
23
</body>
24
-</html>
+</html>
0 commit comments