1. const ajax = (method, url, data, success, fail)=>{
    2. const request = new XMLHttpRequest()
    3. request.open(method, url)
    4. request.onreadystatechange =function (){
    5. if(request.readyState === 4){
    6. if(request.status >= 200 && request.status < 300 || request.status === 304){
    7. success(request)
    8. }else{
    9. fail(request)
    10. }
    11. }
    12. }
    13. request.send()
    14. }