本文介绍了更改功能不起作用jquery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
$( document ).ready(function() {
$(function () {
$.ajax({
type: "POST",
url: "Single_page.aspx/getCity",
data: '{}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (r) {
var ddlCity = $("[id*=ddlCity]");
ddlCity.empty().append('<option selected="selected" value="0">Please Select City </option>');
$.each(r.d, function () {
ddlCity.append($("<option></option>").val(this['Value']).html(this['Text']));
});
}
});
});
});
$('#<%=ddlCity.ClientID %>').change(function () {
alert(cityID);
var cityID = $("[id*=ddlCity] > option[@selected]").attr("value");
alert(cityID);
$("[id *= ddlLocality]").html("");
$.ajax({
type: "POST",
url: "Single_page.aspx/getLocality",
data: "{ID:'" + cityID + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (r) {
var ddlLocality = $("[id*=ddlLocality]");
ddlLocality.empty().append('<option selected="selected" value="0">Please Select City </option>');
$.each(r.d, function () {
ddlLocality.append($("<option></option>").val(this['Value']).html(this['Text']));
});
}
});
});
<asp:DropDownList ID="ddlCity" runat="server" class="form-control" >
</asp:DropDownList>
<asp:DropDownList ID="ddlLocality" runat="server" class="form-control">
</asp:DropDownList>
推荐答案
这篇关于更改功能不起作用jquery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!