"use strict";
cc._RF.push(module, 'b923futHaVBHLgtagiGZo0l', 'net_http');
// net_http.ts

Object.defineProperty(exports, "__esModule", { value: true });
/*
 * @Author: cmd
 * @wechat: cmd_develop
 * @qq群: 790373986
 * @Date: 2019-04-23 15:33:22
 * @Last Modified by: cmd
 * @Last Modified time: 2019-04-23 17:14:25
 * @Description:
 */
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var http = /** @class */ (function (_super) {
    __extends(http, _super);
    function http() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    http.prototype.http_post = function (url, parme) {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                return [2 /*return*/, new Promise(function (resolve, reject) {
                        var xhr = cc.loader.getXMLHttpRequest();
                        xhr.onreadystatechange = function () {
                            if (xhr.readyState === 4 && (xhr.status >= 200 && xhr.status < 300)) {
                                var respone = xhr.responseText;
                                resolve(respone);
                            }
                        };
                        xhr.ontimeout = function (e) {
                            // XMLHttpRequest 超时。在此做某事。
                            resolve('error');
                        };
                        xhr.open("POST", url, true);
                        // note: In Internet Explorer, the timeout property may be set only after calling the open()
                        // method and before calling the send() method.
                        xhr.timeout = 2000; // 5 seconds for timeout
                        xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
                        //let parme = 123;       
                        xhr.send(parme);
                    })];
            });
        });
    };
    http = __decorate([
        ccclass
    ], http);
    return http;
}(cc.Component));
exports.default = http;

cc._RF.pop();