



function NewCategoryFormSubmit()
{
    var form    =  $("#NewCategoryForm")[0];
    var data    =   new FormData(form);
    data.append("request", "new_category");
    $("#NewCategoryFormSB").prop("disabled", true);
    $.ajax
    ({
        type: "POST",
        enctype: 'multipart/form-data',
        url: "../../controllers/category.php",
        data: data,
        processData: false,
        contentType: false,
        cache: false,
        timeout: 600000,
        async: true,
        success: function (response) 
        {
            response    =   JSON.parse(response);
            if((response["error"] == false))
            {
                alert(response["message"]);
                $("#categoryname").val("");
            }
            else
            {
                alert(response["error_msg"]);
            }
            $("#NewCategoryFormSB").prop("disabled", false);

        },
        error: function (e) 
        {
            console.log("ERROR : ", e);
            $("#NewCategoryFormSB").prop("disabled", false);
        }
    });
}











$(document).ready(function () 
{


    $("#NewCategoryForm").validate
    ({
        rules:
        {
            categoryname:
            {
                required: true
            },
        },
        messages:
        {
            categoryname:
            {
                required: "Category Name is required"
            }
        },
    });



    $("#NewCategoryForm").on("submit", function(event)
    {
        event.preventDefault();
        var FS  =   $(this).valid();
        if((FS))
        {
            NewCategoryFormSubmit();
        }

    });






});