AJAX函数的封装

```
function ajax(url,funSucc,fnFaild){
    var xhr = new XMLHttpRequest();
    xhr.open('GET',url,true);
    xhr.send(null);
    xhr.onreadystatechange=function(){
        if (xhr.readyState==4) {
            if (xhr.status==200) {
                funSucc(xhr.responseText);



            }else{
                fnFaild(xhr.statusText);

                }

            }
        }
    }

“`

原文地址:https://www.cnblogs.com/jiandanshishu/p/12953331.html