Jquery获取更改事件
Jquery获取更改事件,jquery,asp.net-mvc,Jquery,Asp.net Mvc,我有以下代码: <script> function GetDetails(id) { $.ajax({ url: "@Url.Action("EditRecord","TeamPlans")" + "/" + id, type: "GET", contentType: "application/json;charset=UTF-8", dataType: "json", success: func
我有以下代码:
<script>
function GetDetails(id) {
$.ajax({
url: "@Url.Action("EditRecord","TeamPlans")" + "/" + id,
type: "GET",
contentType: "application/json;charset=UTF-8",
dataType: "json",
success: function (response) {
$('#hfId').val(response.ActivityPlanId);
$('#txtActivityPlanName').val(response.ActivityPlanName);
$("#CountryId").val(response.OrganizationNumber);
$('#StateId').val(response.Assignee);
$('#modal-Update').modal('show');
},
error: function (response) {
alert(response.responseText);
}
});
return false;
}
</script>
函数GetDetails(id){
$.ajax({
url:“@url.Action”(“编辑记录”、“团队计划”)“+”/“+id,
键入:“获取”,
contentType:“应用程序/json;字符集=UTF-8”,
数据类型:“json”,
成功:功能(响应){
$('#hfId').val(response.ActivityPlanId);
$('#txtActivityPlanName').val(response.ActivityPlanName);
$(“#CountryId”).val(response.OrganizationNumber);
$('#StateId').val(response.Assignee);
$(“#模式更新”).modal('show');
},
错误:函数(响应){
警报(response.responseText);
}
});
返回false;
}
然后我还有以下代码:<script>
$(document).ready(function () {
$("#CountryId").change(function () {
$.get("@Url.Action("GetStateList","TeamPlans")", { sOId: $("#CountryId").val() }, function (data) {
//$("#StateId").empty();
$.each(data, function (index, row) {
$("#StateId").append("<option value='" + row.PositionNumber + "'>" + row.Name + "</option>")
});
});
})
});
$(文档).ready(函数(){
$(“#CountryId”).change(函数(){
$.get(@Url.Action(“GetStateList”,“TeamPlans”),{sOId:$(“#CountryId”).val()},函数(数据){
//$(“#StateId”).empty();
$.each(数据、函数(索引、行){
$(“#StateId”).append(“+row.Name+”)
});
});
})
});
我的问题是,在模态更新显示之前,如何在第一个脚本上执行第二个脚本<代码>#CountryId在执行url:@url.Action(“EditRecord”,“TeamPlans”)“+”/“+id,
请帮忙。谢谢。我假设显示详细信息的按钮具有class.detail,您可以将
ajaxStart
绑定到.detail按钮
$(".detail").ajaxStart(function(){
$("#CountryId").change(function () {
$.get("@Url.Action("GetStateList","TeamPlans")", { sOId: $("#CountryId").val() }, function (data) {
//$("#StateId").empty();
$.each(data, function (index, row) {
$("#StateId").append("<option value='" + row.PositionNumber + "'>" + row.Name + "</option>")
});
});
})
})
$(“.detail”).ajaxStart(函数(){
$(“#CountryId”).change(函数(){
$.get(@Url.Action(“GetStateList”,“TeamPlans”),{sOId:$(“#CountryId”).val()},函数(数据){
//$(“#StateId”).empty();
$.each(数据、函数(索引、行){
$(“#StateId”).append(“+row.Name+”)
});
});
})
})
更多