可以这么回答:
1原生Ajax的实现步骤:
1.创建对象
var xhr=new XMLHttpRequest()
2.打开浏览器
xhr.open('GET'/'post','请求地址')
3.发送请求
xhr.send()
4.根据发送请求返回的状态码决定状态
xhr.onreadystatechange=function(){
if(this.readyState==4&&this.status==200){
//5.请求成功
console.log(this.responseText)
}else{
}
}
2.什么情况下会导致跨域:
不同源策略时会导致跨域
协议不同、
端口号不同、
域名不同
IP地址不同
网址不同
这些都会导致跨域;