How to assign value to dropdown with ajax in asp.net mvc

Sep 29, 2019

Hi Sir, I need to load dropdown value returned in ajax success function to the page but every time it gets a null value.

currently, I am using the following method:


    $(document).ready(function () {
        $.ajax({
            url: '/PurchaseOrder/getDefaultCostCentreandDepartment',
            type: 'post',
            data: {
                'dummydata': 7
            },
            success: function (r) {
                console.log(r);
                $('#CostCenterId_FK').val(r.CostCenterId_FK);
                $('#DepartmentId_FK').val(r.DepartmentId_FK);

            },
            error: function (r) {
                console.log(r);
            }
        });

    });
the above method is not working, please guide me through the way.



  1. No comment Available


Add Your Comment