Thursday, December 15, 2016

Json POST Request in Java Script

$("#btnSave").bind("click", function () {

            if ($('#txtCategory').val() != "") {

                var data = JSON.stringify({
                    'Category': $('#txtCategory').val(),
                    'Status': $('#chkVisible').is(':checked')
                });

                $.ajax({
                    url: '/Admin/InsertCategory',
                    type: 'POST',
                    data: data,
                    dataType: 'json',
                    contentType: 'application/json; charset=utf-8',
                    success: function (data) {
                       
                    }
                }).fail(function (xhr, textStatus, err) {

                });
            }
            else {
                alert("You must fill category name!");
            }
        });

No comments:

Post a Comment