Ajax call to populate select list when another select list changes

后端 未结 1 720
旧时难觅i
旧时难觅i 2021-01-14 02:53

Following on from this post, I\'m attempting to populate a select list of \'cities\' when another select list of \'countries\' changes. I followed the same approach as the

1条回答
  •  情话喂你
    2021-01-14 03:34

    SOLVED

    $('#Country').change(function () {
        var selectedValue = $(this).val();
        $.get({
            url: '@Url.Action("CityDropDownList", "Home")',
            data: { country: selectedValue },
    
            success: function (result) {
    
                alert(result);
                var cities = $('#City');
                cities.empty();
    
                $.each(result, function () {
    
                    cities.append(
                            $('

    0 讨论(0)
提交回复
热议问题