XMLHTTRequest错误处理响应状态

时间:2017-01-26 19:38:42

标签: javascript http

let httpRequest = new XMLHttpRequest();
let FHIRserverAddress = '192.168.200.139:3012';
let url = 'http://' + FHIRserverAddress + '/model?starttime=' + startTime + '&endtime=' + endTime;
httpRequest.open('GET', url);
httpRequest.send();
httpRequest.onreadystatechange = function () {
    if (httpRequest.readyState == 4 && httpRequest.status == 200) {
        let currentModel = JSON.parse(httpRequest.responseText);
        console.log('returning a valid model');
        return callback(null, currentModel);
    } else if (httpRequest.status != 200) {
        console.log('get model call failed');
    }
};

我可以看到Chrome开发工具中的网络通话和返回的响应状态为200.上述通话总是得到0表示请求状态。

任何人都会看到我做错了什么?

0 个答案:

没有答案