Pushkar Pushp

Pushkar Pushp

  • NA
  • 92
  • 5.8k

What is the error in this code

Feb 14 2019 12:02 AM
@section Scripts {
<script>
$(".populateState").on("change", function () {
populateState($(this).val());
})
function populateState(val) {
$.getJSON('@Url.Action("GetStateList", "Buyer")' + "?value=" + val, function (result) {
$(".StateDD").html(""); // makes select null before filling process
var data = result.data;
console.log("---------" + data.length);
if (data.length != 0) {
for (var i = 0; i < data.length; i++) {
$(".StateDD").append("<option value=" + data[i].StateID + ">" + data[i].StateName + "</option>")
}
}
else {
$(".StateDD").append("<option value= 0>No State Added</option>")
populateCity(val, "country");
}
})
}

Answers (1)