var xhr = new XMLHttpRequest();
xhr.open("GET", url, false);
xhr.send();
document.getElementById("res").innerText = xhr.responseText;

如何获取到 response 对象
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
你需要学习ajax的基本用法,和跨域无关.
你这不是跨域问题吧,前端基础不行吧~
PS:后端看你用的php7.如果要设置跨域使用