undefined url dropdown change based on another

Iam working on asp.net core project, am facing minor problem on populating districts based on region. when i select a region i get undefined url.

<select id="Select_District"     data_url ="@Url.Action("GetDistricts")"     asp-for="DistrictId"     asp-items="@Model.Districts"     class="" disabled="disabled">   <option value="">Please select one</option> </select> <label>District</label> 

Dropdown change event

$("#Select_Region").change(function () { $("#Select_District").removeAttr("disabled"); var v = $(this).val(); var url = $("#Select_District").data("url") + '?u=' + v; var $fac= $("#Select_District"); $.getJSON(url, function (data) {     $fac.empty();     $.each(data, function (i, item) {         $fac.append($("<option>").text(item.Text).val(item.Value));     }); }); 
Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.