2023西安数博会CIM演示-【前端】-Web
AdaKing88
2023-08-21 bc03b832caa49bbcd2674fe4cae3701b5059bf95
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
function request(options) {
    var oReq = new XMLHttpRequest();
    oReq.open("GET", options.url, false);
    oReq.responseType = options.type;
    oReq.onload = function (result) {
        if (result) {
            var _data = null;
            if (oReq.responseType == "text" || oReq.responseType == "") {
                _data = result.target.responseText;
            } else {
                _data = result.target.response;
            }
            if (result.target.status == 200) {
                if (typeof options.success == "function")
                    options.success(_data);
            } else {
                if (typeof options.error == "function") options.error(_data);
            }
        }
    };
    oReq.send(null);
    oReq.onloadend = function () {
        oReq = null;
    };
}