javascript中的Ajax基础(一)

一、手写一个ajax

网站建设哪家好,找成都创新互联!专注于网页设计、网站建设、微信开发、小程序设计、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了屏边免费建站欢迎大家使用!

 1 const xhr = new xmlHttpRequest()
 2 
 3 xhr.open(请求方式:post get, 请求地址, 同步或者异步)
 4 
 5 xhr.onreadyStateChange = function(){
 6    if(xhr.readyState===4){
 7      if(xhr.status === 200) {
 8        console.log(xhr.responseText)  
 9       }
10    }
11 }
12 
13 xhr.send(请求参数)

分享文章:javascript中的Ajax基础(一)
浏览路径:http://myzitong.com/article/dsojhoo.html