1. function ajax({
    2. url,
    3. method = "get",
    4. success
    5. }){
    6. var xhr = new XMLHttpRequest();
    7. xhr.open(method,url,true);
    8. xhr.send();
    9. xhr.onreadystatechange = function(){
    10. if(xhr.readyState == 4 && xhr.status == 200){
    11. var result = JSON.parse(xhr.responseText);
    12. success(result)
    13. }
    14. }
    15. }