1. getTxt() {
    2. var xhr = new XMLHttpRequest();
    3. xhr.open("get", "a.txt", true);
    4. xhr.send();
    5. xhr.onreadystatechange = function() {
    6. if(xhr.readyState == 4 && xhr.status == 200) {
    7. console.log(xhr, '本地对象');
    8. console.log(xhr.responseText, 'txt内容');
    9. } else if(xhr.status == 404) {
    10. console.log(xhr.status, '23333333');
    11. }
    12. };
    13. },