1. 程式人生 > >原生JS的HTTP請求

原生JS的HTTP請求

font sch 原生 office 請求 ref html sof nbsp

ar xhr = new XMLHttpRequest();

xhr.onreadystatechange = function(){

if( xhr.readyState == 4){

if( xhr.status >= 200 && xhr.status < 300 || xhr.status == 304){

info.innerHTML = xhr.responseText;

}

}

};

xhr.open("get","test.txt",true);

xhr.send(null);

原生JS的HTTP請求