<script>


    $("#Withdraw_money_modal #WithdrawBtn").on('click', function () {

        let selector = $(this);

        var dataSet0 = {
            "user_id":  $("#Withdraw_money_modal #user_id").val(),
            "amount": parseFloat($("#Withdraw_money_modal #amount").val()),
            "bank": parseFloat($("#Withdraw_money_modal #bank").val()),
        };

        $.ajax({
            url: "<?=  site_url("ajax/delivery/requestWithdrawal")?>",
            data: dataSet0,
            dataType: 'json',
            type: 'POST',
            beforeSend: function (xhr) {
                NSTemplateUIAnimation.button.loading = selector;
            }, error: function (request, status, error) {
                NSAlertManager.simple_alert.request = "<?=Translate::sprint("Input invalid")?>";

                NSTemplateUIAnimation.button.default = selector;
                console.log(request)
            },
            success: function (data, textStatus, jqXHR) {

                console.log(data);

                if (data.success === 1) {

                    NSTemplateUIAnimation.button.success = selector;
                    $("#Withdraw_money_modal").modal('hide');
                    document.location.reload();

                } else if (data.success === 0) {
                    NSTemplateUIAnimation.button.default = selector;
                    var errorMsg = "";
                    for (var key in data.errors) {
                        errorMsg = errorMsg + data.errors[key] + "<br/>";
                    }
                    if (errorMsg !== "") {
                        NSAlertManager.simple_alert.request = errorMsg;
                    }
                }
            }
        });

        return false;

    });



</script>