Skip to content

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

@Emmanuelf7

Description

@Emmanuelf7

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');

            }


        });

    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions