const ajax = (method,url,data,success,fail)=>{ let request = new XMLHttpRequest() request.open(method,url) request.onreadystatechange = function(){ if(request.readyState === 4){ if(request.status >=200 && request <=300 || request.status == 304){ success(request) }else{ fail(request) } } } request.end() }