我的视图中有以下脚本:-
<script type="text/javascript">
$(document).ready(function () {
$("#Server_VirtualCenterID").attr("disabled", "disabled");
if ($(this).val() == "3") {
$("#Server_VirtualCenterID").removeAttr("disabled");
}
else {
$("#Server_VirtualCenterID").attr("disabled", "disabled");
}
$("#Switch_RackID").change(function () {
var idRack = $(this).val();
$.getJSON("/Rack/LoadDataCenterByRack", { id: idRack },
function (RackData) {
var select = $("#Switch_TMSRack_DataCenter_Name");
select.empty();
select.append(Text);
});
});
});
</script>
当下拉列表更改时,它将调用以下操作方法:-
public JsonResult LoadDataCenterByRack(int id)
{
string datacentername = repository.FindRack(id).DataCenter.Name;
var DCData = new { Text = datacentername, Value = datacentername };
return Json(DCData, JsonRequestBehavior.AllowGet);
}
但是返回的 json 不会作为Switch_TMSRack_DataCenter_Name
输入字段的文本添加?任何人都可以建议吗?