json 데이터를 사용하여 국가 목록, 상태 목록 도시 목록을 드롭 다운 목록에 바인딩합니다. 내 요구 사항은 국가를 기반으로 변경해야합니다. 미국을 기준으로 도시 가치가 바뀌어야합니다. 내가 인도를 처음으로 선택했다면 각각의 주들이오고 있다고 가정 해 보겠습니다. 그러나 국가의 국가 이름을 변경 한 후 새로운 값이 국가 드롭 다운에서 업데이트되지 않습니다. 방화범이 들린 국가의 정확한 데이터를 얻고 있습니다.첫 번째 드롭 다운 값이 변경된 후 연결 드롭 다운 값이 변경되지 않습니다.
내 Jsfile :
$(document).ready(function() {
bindData();
BindCountry();
var DropDown1 = $("#ddlCountry");
DropDown1.change(function (e) {
var CountryCode = DropDown1.val();
if (CountryCode >= 1) {
GetStates(CountryCode);
}
});
});
function BindCountry() {
var Dropdown1 = $("#ddlCountry");
$.ajax({
type: "POST",
url: location.pathname + "/GetCountry",
data: "{}",
contentType: "application/json;charset=utf-8",
datatype: "json",
success: function (response) {
var country = response.d;
$.each(country, function (index, country) {
Dropdown1.append('<option value="' + country.CountryCode + '">' + country.Country + '</option>');
});
},
failure: function (msg) {
alert(msg);
}
});
}
function GetStates(Coun_code) {
var DdlState = $("#ddlState");
$.ajax({
type: "POST",
url: location.pathname + "/GetStates",
data: "{'CountryCode':'" + Coun_code + "'}",
contentType: "application/json;charset=utf-8",
datatype: "json",
success: function (response) {
var state = response.d;
$.each(state, function (index, state) {
DdlState.append('<option value="' + state.StateCode + '">' + state.StateName + '</option>');
});
},
failure: function (msg) {
alert(msg);
}
});
}
는 Autopost 다시 asp.net 같은 속성이 자바 스크립트 여기에있다인가? 내가 당신의 국가의 섹션에서 거짓 수익을 추가 한 때문에
을 시도하지 않은, 존재하는 일이있을 수 있는가? 그 타격 방법인가요? –
모든 게 잘된 것 같은데, 나는 정확한 데이터를 얻고있다 ... 나는 질문에 언급했듯이 처음부터 잘 작동한다. 그러나 두 번째로 국가 이름을 변경 한 후에 각각의 변경 사항은 나머지 두 개의 드롭 다운에 반영되지 않습니다 –