if (typeof module === 'object') {
    window.jQuery = window.$ = module.exports;
}
function FoFJsCodeJQAjax(Url, IfType, Data, timeout, contentType_, application, ifDataObj) {
    if (jQueryWebisObject(Url) == false) {
        return FoFJsCodeJQAjax3(Url, IfType, Data, timeout, contentType_, application, ifDataObj)
    }
    timeout = typeof timeout !== 'undefined' ? timeout : 5000;
    ifDataObj = typeof ifDataObj !== 'undefined' ? ifDataObj : [];
    application = typeof application !== 'undefined' ? application : [];
    if (IfType == true) {
        IfType = "POST";
    } else {
        IfType = "GET";
    }
    let RetData = "";
    let DataObj = {
        url: Url,
        data: Data,
        async: false,
        type: IfType,
        timeout: timeout,
        beforeSend: function (AJAX) {
            for (let index = 0; index < application.length; index++) {
                AJAX.setRequestHeader(application[index]["名称"], application[index]["值"]);
            }
        },
        success: function (result, textStatus, xhr) {
            if (ifDataObj.length >= 1) {
                RetData = {}
                RetData["返回数据"] = result
                for (let index = 0; index < ifDataObj.length; index++) {
                    RetData[ifDataObj[index]] = xhr.getResponseHeader(ifDataObj[index])
                    RetData["所有协议头"] = xhr.getAllResponseHeaders()

                }
            } else {
                RetData = result;
            }

        },
        complete: function (XMLHttpRequest, status) {
            if (status == 'timeout') { // 判断超时后 执行
                RetData = "错误请求"
            }
        },
        error: function (xhr, status, error) {
            RetData = "错误请求"
        }
    }
    if (contentType_ != undefined) {
        DataObj["contentType"] = contentType_
    }
    if (jQueryWebisObject(Url) == true) {
        DataObj["url"] = Url["地址"]
        if (DataObj["返回二进制"] == true) {
            DataObj["xhrFields"] = {
                responseType: 'blob' // 设置为blob，表示服务器响应的数据应为二进制blob  
            }
        }
    }
    $.ajax(DataObj);
    return RetData;
}
function FoFJsCodeJQAjax2(Url, IfType, funCk, Data, timeout, contentType_, application, ifDataObj) {
    if (jQueryWebisObject(Url) == false) {
        FoFJsCodeJQAjax4(Url, IfType, funCk, Data, timeout, contentType_, application, ifDataObj)
        return 
    }
    timeout = typeof timeout !== 'undefined' ? timeout : 5000;
    application = typeof application !== 'undefined' ? application : [];
    ifDataObj = typeof ifDataObj !== 'undefined' ? ifDataObj : [];
    if (IfType == true) {
        IfType = "POST";
    } else {
        IfType = "GET";
    }
    let DataObj = {
        url: Url,
        data: Data,
        type: IfType,
        timeout: timeout,
        beforeSend: function (AJAX) {
            for (let index = 0; index < application.length; index++) {
                AJAX.setRequestHeader(application[index]["名称"], application[index]["值"]);
            }
        },
        success: function (blob, textStatus, xhr) {
            if (funCk != undefined) {
                let ifByte = false;
                if (jQueryWebisObject(Url) == true) {
                    if (Url["返回base64"] == true) {
                        ifByte = true;
                    }
                }
                if (ifDataObj.length >= 1) {
                    let RetData = {}
                    if (ifByte == false) {
                        RetData["返回数据"] = blob
                        for (let index = 0; index < ifDataObj.length; index++) {
                            RetData[ifDataObj[index]] = xhr.getResponseHeader(ifDataObj[index])
                            RetData["所有协议头"] = xhr.getAllResponseHeaders()
                        }
                        funCk(RetData);
                    } else {
                        var reader = new FileReader();
                        reader.onloadend = function () {
                            var base64data = reader.result;
                            RetData["返回数据"] = base64data
                            for (let index = 0; index < ifDataObj.length; index++) {
                                RetData[ifDataObj[index]] = xhr.getResponseHeader(ifDataObj[index])
                                RetData["所有协议头"] = xhr.getAllResponseHeaders()
                            }
                            funCk(RetData);
                        };
                        reader.readAsDataURL(blob);
                    }
                } else {
                    if (ifByte == false) {
                        funCk(blob);
                    } else {
                        var reader = new FileReader();
                        reader.onloadend = function () {
                            var base64data = reader.result;
                            funCk(base64data);
                        };
                        reader.readAsDataURL(blob);
                    }
                }
            }
        },
        complete: function (XMLHttpRequest, status) {
            if (status == 'timeout') { // 判断超时后 执行
                if (funCk != undefined) {
                    funCk("错误请求");
                }
            }
        },
        error: function (xhr, status, error) {
            if (funCk != undefined) {
                funCk("错误请求");
            }
        }
    }
    if (contentType_ != undefined) {
        DataObj["contentType"] = contentType_;
    }
    if (jQueryWebisObject(Url) == true) {
        DataObj["url"] = Url["地址"]
        if (Url["返回base64"] == true) {
            DataObj["xhrFields"] = {
                responseType: 'blob' // 设置为blob，表示服务器响应的数据应为二进制blob  
            }
        }
    }
    $.ajax(DataObj);
}
function jQueryWebisObject(item) {
    return Object.prototype.toString.call(item) === '[object Object]' ||
        typeof item === 'function' ||
        Array.isArray(item);
    // 还可以添加其他类型检查，如 Date、RegExp 等  
}
function FoFJsCodeJQAjax3(Url, IfType, Data, timeout, contentType_, application, ifDataObj) {
    timeout = typeof timeout !== 'undefined' ? timeout : 5000;
    ifDataObj = typeof ifDataObj !== 'undefined' ? ifDataObj : [];
    if (contentType_ == undefined) {
        application = typeof application !== 'undefined' ? application : [];
        if (IfType == true) {
            IfType = "POST";
        } else {
            IfType = "GET";
        }
        let RetData = "";
        $.ajax({
            url: Url,
            data: Data,
            async: false,
            type: IfType,
            timeout: timeout,
            beforeSend: function (AJAX) {
                for (let index = 0; index < application.length; index++) {
                    AJAX.setRequestHeader(application[index]["名称"], application[index]["值"]);
                }
            },
            success: function (result, textStatus, xhr) {
                if (ifDataObj.length >= 1) {
                    RetData = {}

                    RetData["返回数据"] = result
                    for (let index = 0; index < ifDataObj.length; index++) {
                        RetData[ifDataObj[index]] = xhr.getResponseHeader(ifDataObj[index])
                        RetData["所有协议头"] = xhr.getAllResponseHeaders()

                    }
                } else {
                    RetData = result;
                }

            },
            complete: function (XMLHttpRequest, status) {
                if (status == 'timeout') { // 判断超时后 执行
                    RetData = "错误请求"
                }
            },
            error: function (xhr, status, error) {
                RetData = "错误请求"
            }
        });
        return RetData;
    } else {
        application = typeof application !== 'undefined' ? application : [];
        if (IfType == true) {
            IfType = "POST";
        } else {
            IfType = "GET";
        }
        let RetData = "";
        $.ajax({
            url: Url,
            data: Data,
            async: false,
            type: IfType,
            timeout: timeout,
            contentType: contentType_,
            beforeSend: function (AJAX) {
                for (let index = 0; index < application.length; index++) {
                    AJAX.setRequestHeader(application[index]["名称"], application[index]["值"]);
                }
            },
            success: function (result, textStatus, xhr) {
                if (ifDataObj.length >= 1) {
                    RetData = {}
                    RetData["返回数据"] = result
                    for (let index = 0; index < ifDataObj.length; index++) {
                        RetData[ifDataObj[index]] = xhr.getResponseHeader(ifDataObj[index])
                        RetData["所有协议头"] = xhr.getAllResponseHeaders()
                    }
                } else {
                    RetData = result;
                }
            },
            complete: function (XMLHttpRequest, status) {
                if (status == 'timeout') { // 判断超时后 执行
                    RetData = "错误请求"
                }
            },
            error: function (xhr, status, error) {
                RetData = "错误请求"
            }
        });
        return RetData;
    }

}
function FoFJsCodeJQAjax4(Url, IfType, funCk, Data, timeout, contentType_, application, ifDataObj) {
    timeout = typeof timeout !== 'undefined' ? timeout : 5000;
    application = typeof application !== 'undefined' ? application : [];
    ifDataObj = typeof ifDataObj !== 'undefined' ? ifDataObj : [];
    if (IfType == true) {
        IfType = "POST";
    } else {
        IfType = "GET";
    }
    if (contentType_ == undefined) {
        $.ajax({
            url: Url,
            data: Data,
            type: IfType,
            timeout: timeout,
            beforeSend: function (AJAX) {
                for (let index = 0; index < application.length; index++) {
                    AJAX.setRequestHeader(application[index]["名称"], application[index]["值"]);
                }
            },
            success: function (result, textStatus, xhr) {
                if (funCk != undefined) {
                    if (ifDataObj.length >= 1) {
                        let RetData = {}
                        RetData["返回数据"] = result
                        for (let index = 0; index < ifDataObj.length; index++) {
                            RetData[ifDataObj[index]] = xhr.getResponseHeader(ifDataObj[index])
                            RetData["所有协议头"] = xhr.getAllResponseHeaders()
                        }
                        funCk(RetData);
                    } else {
                        funCk(result);
                    }
                }
            },
            complete: function (XMLHttpRequest, status) {
                if (status == 'timeout') { // 判断超时后 执行
                    if (funCk != undefined) {
                        funCk("错误请求");
                    }
                }
            },
            error: function (xhr, status, error) {
                if (funCk != undefined) {
                    funCk("错误请求");
                }
            }
        });
    } else {
        $.ajax({
            url: Url,
            data: Data,
            type: IfType,
            timeout: timeout,
            contentType: contentType_,
            beforeSend: function (AJAX) {
                for (let index = 0; index < application.length; index++) {
                    AJAX.setRequestHeader(application[index]["名称"], application[index]["值"]);
                }
            },
            success: function (result, textStatus, xhr) {
                if (funCk != undefined) {
                    if (ifDataObj.length >= 1) {
                        let RetData = {}
                        RetData["返回数据"] = result
                        for (let index = 0; index < ifDataObj.length; index++) {
                            RetData[ifDataObj[index]] = xhr.getResponseHeader(ifDataObj[index])
                            RetData["所有协议头"] = xhr.getAllResponseHeaders()
                        }
                        funCk(RetData);
                    } else {
                        funCk(result);
                    }
                }
            },
            complete: function (XMLHttpRequest, status) {
                if (status == 'timeout') { // 判断超时后 执行
                    if (funCk != undefined) {
                        funCk("错误请求");
                    }
                }
            },
            error: function (xhr, status, error) {
                if (funCk != undefined) {
                    funCk("错误请求");
                }
            }
        });
    }

}