JSON HTTP响应-获取单个整数

JSON HTTP response - get a single integer

本文关键字:单个 整数 获取 HTTP 响应 JSON      更新时间:2023-09-26

我试图显示一个作为HTTP响应的个位数整数(0和1)。我不知道如何获取并存储该整数?我应该使用什么功能?

    http_request.onreadystatechange = function() {
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                // ...what goes here?...
            }
            setTimeout("loadJSON()", 1000);
        }
    }
    http_request.open("GET", data_file, true);
    http_request.send();
}

类似AJAX调用的响应可以从responseText属性访问:

if (http_request.status == 200) {
    doStuffWith(http_request.responseText);
}