JavaScript libraries are not working inside Ajax

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}

<script type="text/javascript">      
       
    
    function notyfy() {
        $.notify({
            message: "Hello"
        }, {
            type: 'danger'
        });
    }

    notyfy();//THis works

    
    $("#btnSave").click(function (e) {       
        savedata();
    });

    function savedata() {
        var items = new Array();
        $("#tblGRN TBODY TR").each(function () {
            var row = $(this);
            var item = {
                'PoNo': $("#PoNo").val(),
                'FundSource': $("#FundSource").val(),
                'Vote': $("#Vote").val(), 
                'Total': row.find("TD").eq(5).html(),
                'InvoiceNo': $("#InvoiceNo").val(),
                'ReceivedDate': $("#ReceivedDate").val(),
                'Note': $("#Note").val()
            }    
            items.push(item);
        });
       
        $.ajax({
            type: "POST",
            url: "/GRN/Create",
            data: JSON.stringify(items),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (r) {
                notyfy(); //This do not work
                alert(r.responseText);
                console.log(r);
                $("#tbody").empty();
                window.location = "/GRN/Create";
            }
        });
    }
</script>

$.notify is not a function

$.notify works outside without any issue. anything I put inside the success function giving me not a function. all libraries are working fine outside the ajax. The whole script part is above. please help me to solve the issue in this.

Upvotes: 0

Views: 45

Answers (0)

Related Questions