首页 > 代码库 > 原生JS的HTTP请求

原生JS的HTTP请求

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请求