23Jul 跨域请求测试 Access-Control-Allow-Origin Jul 23, 2021 By 余钊 1353 Views 0 Comments 在浏览器控制台中输入下面代码来测试: var xhr = new XMLHttpRequest(); xhr.open('GET', 'https://www.xxx.com/api/action'); xhr.send(null); xhr.onload = function(e) { var xhr = e.target; console.log(xhr.responseText); } 如果接口不允许跨域访问会提示下面错误。 No 'Access-Control-Allow-Origin' header is present on the requested resource. 转载请注明出处: http://bluesd7.com/蓝影闪电的随笔/ContentId/420/跨域请求测试-Access-Control-Allow-Origin 标签: 分类: 后端开发, 前端开发, 原创