哪位大哥能帮我写个原生的 JS getJSON

哪位大哥能帮我写个原生的 JS getJSON,在此感谢了。
不是异步请求,
请求地址:get2.php?uuid=sssssss
失败返回的JSON

{"error_code": 0, "reason": "success", "resultcode": 200, "qr_code": null}
点击按钮后执行一秒轮询一次get2.php?uuid=sssssss
每轮询一次,按钮上的标题显示次数。
轮询35秒后qr_code还是null,就让用户点击刷新页面。
直到qr_code 栏里是URL 地址。然后执行第二次 请求,请求地址:get5555.php?url=把刚取出qr_code的值。然后得到get5555.php返回的值,弹窗显示

现有实现一次请求的源码。我需要实现两次不同请求地址

 <input type="button" id="but" value="开始" onclick="run(1);" />
<script type="text/javascript">
function run(n) {
    var xhr = new XMLHttpRequest();
    xhr.open('get','get2.php?uuid=sssssss&time='+new Date().getTime());
    xhr.onreadystatechange = function () {
        if (xhr.readyState==4 &&xhr.status==200) {
            document.getElementById("but").value = n;
            var data = JSON.parse(xhr.responseText);
            if (data.qr_code!=null) {
                location.href = data.qr_code;
            } else if (n<35) {
                setTimeout(function(){
                    run(n+1);
                }, 1000);
            } else {
                alert("刷新页面");
                location.reload();
            }
        }
    }
    xhr.send();
}
</script>
<input type="button" id="but" value="开始" onclick="run(1);" />
<script type="text/javascript">

function getAjax(url,callback) {
    var xhr = new XMLHttpRequest();
    xhr.open('get',url+(url.indexOf("?")==-1?"?":"&")+'time='+new Date().getTime());
    xhr.onreadystatechange = function () {
        if (xhr.readyState==4 &&xhr.status==200) {
            callback(xhr.responseText);
        }
    }
    xhr.send();
}

function run(n) {
    getAjax("get2.php?uuid=sssssss",function (data) {
        document.getElementById("but").value = n;
        data = JSON.parse(data);
        if (data.qr_code!=null) {
            getAjax("get5555.php?url="+encodeURIComponent(data.qr_code),function (data) {
                alert(data);
            });
        } else if (n<35) {
            setTimeout(function(){
                run(n+1);
            }, 1000);
        } else {
            alert("刷新页面");
            location.reload();
        }
    });
}
</script>