$(document).ready(function(){
    $("#login").click(function(){

        var action = $("#lg-form").attr('action');
        var form_data = {
            username: $("#username").val(),
            password: $("#password").val(),
            is_ajax: 1
        };

        $.ajax({
            type: "POST",
            url: action,
            data: form_data,
            success: function(response)
            {
                if(response == "success")
                    swal.fire({
                        text: "Validasi User dan Password, OK!",
                        icon: "success",
                        buttonsStyling: false,
                        confirmButtonText: "Ok",
                        timer: 1500,
                        customClass: {
                            confirmButton: "btn font-weight-bold btn-light-primary"
                        }
                    }).then(function () {
                        // $.redirect(BASE_URL + "index.php/athirahmin/ceklogin/", {user: "johnDoe", password: "12345"}, "POST", "_blank");


                        // KTUtil.scrollTop();/
                        window.location = BASE_URL + "dashboard";
                    });
                else
                   swal.fire({
                        text: "Sorry, user or password not valid, please try again.",
                        icon: "error",
                        buttonsStyling: false,
                        confirmButtonText: "Ok, got it!",
                        customClass: {
                            confirmButton: "btn font-weight-bold btn-light-primary"
                        }
                    }).then(function () {
                        // KTUtil.scrollTop();
                        window.location = BASE_URL + "athirahmin";
                    });
            }
        });
        return false;
    });
});