ajax原生写法

195次阅读
没有评论
function Dget(url,callback) {var xhr = new XMLHttpRequest();
        xhr.open("get",url,true);
        xhr.send();
        xhr.onreadystatechange = function(){if (xhr.readyState == 4) {if (xhr.status>=200 && xhr.status<300) {if(callback!=undefined){callback(xhr.responseText);
                    }
                };
            };
        }
    }

    Dget("http://demo.com", function(res){location.href = res})
正文完
有偿技术支持加微信
post-qrcode
 
评论(没有评论)
验证码