let frm = document.getElementById('formulario');
document.addEventListener('DOMContentLoaded', function () {
    var forms = document.getElementsByClassName('needs-validation');
    // Loop over them and prevent submission
    var validation = Array.prototype.filter.call(forms, function (form) {
        form.addEventListener('submit', function (event) {
            event.preventDefault();
            if (form.checkValidity() === false) {
                event.stopPropagation();
                form.classList.add('was-validated');
            } else {
                const url = base_url + 'admin/cambiarEmpresa';
                const formData = new FormData(frm);
                const http = new XMLHttpRequest();
                http.open("POST", url, true);
                http.send(formData);
                http.onreadystatechange = function () {
                    if (this.readyState == 4 && this.status == 200) {
                        const res = JSON.parse(this.responseText);
                        alertas(res.msg, res.icono);
                    }
                }
            }

        }, false);
    });
})