简体   繁体   中英

Cascading dropdown list in asp .net core

All guids I try using cascade dropdown lists States and Cities but return "undefined" Model file States.cs: 在此处输入图像描述

Model file Cities.cs: 在此处输入图像描述

controller: 在此处输入图像描述

view file Cities.cshtml: 在此处输入图像描述

cities table: 在此处输入图像描述

states table: 在此处输入图像描述

after run project and select a state show this result: 在此处输入图像描述

Please add console.log(cities) to check the response:

$.each(data, function (i, cities) {
    console.log(cities); //add this...
    items += "<option value='" + cities["citiesId"] + "'>" + cities["cityName"] + "</option>";
});

Then you will find the property name in response is camel case .

So you need change code like below(eg change cities["CitiesId"] to cities["citiesId"] ):

items += "<option value='" + cities["citiesId"] + "'>" + cities["cityName"] + "</option>";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM