Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Submit button brings sweetalert popup without saving data in the database #1003

Open
Emmanuelf7 opened this issue Mar 4, 2023 · 0 comments

Comments

@Emmanuelf7
Copy link

Emmanuelf7 commented Mar 4, 2023

function saveCategory() {

        var category = new Object();
        category.CategoryId = $("#categoryId").val();
        category.CategoryName = $("#categoryName").val();
        category.Status = $("#status").val();
        var data = JSON.stringify({
            category: category
        });

        document.getElementById('success-message').onclick = function () {
            swal('Success!', 'Category is Saved!', 'success')
        };
        swal({              
            
                Position:'top-end',
                icon: "success",
                title: 'Your work has been saved',
                showConfirmButton: false,
                timer:1500
           
        }).then(function (isConfirm) {
            if (isConfirm) {

                return $.ajax({
                    contentType: 'application/json; charset=ut-8',
                    dataType: 'json',
                    type: 'POST',
                    url: "/Home/SaveCategory",
                    data: data,
                    success: function (result) {
                        if (result == true) {
                            GetAllCategory();
                            dataTable.ajax.reload();
                   
                        }
                    }
                });
            } else {
                
                swal("Cancelled", "You have Cancelled Form Submission!", "error");
                $("#categoryModal").modal('hide');

            }


        });

    }
@Emmanuelf7 Emmanuelf7 changed the title sweetalert popup without saving data in the database Submit button brings sweetalert popup without saving data in the database Mar 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant