封装一个原生的AJAX请求

 

  • - let xhr = new XMLHttpRequest()
    
    - xhr.onreadystatechange=function(){
    
      if(xhr.readystate===4&&xhr.status===200){
    
      console.log(xhr.response)
    
      } 
    
      }
    
    - xhr.open(请求方法,请求地址)
    
    - xhr.send()
    

      

posted @ 2021-11-24 11:20  七友の  阅读(21)  评论(0)    收藏  举报