I am currently facing an issue with the script in my View:-
<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>
This script is supposed to trigger an action method when a dropdown list is changed as shown below:-
public JsonResult LoadDataCenterByRack(int id)
{
string datacentername = repository.FindRack(id).DataCenter.Name;
var DCData = new { Text = datacentername, Value = datacentername };
return Json(DCData, JsonRequestBehavior.AllowGet);
}
However, I am encountering an issue where the returned JSON data is not being added as text for the Switch_TMSRack_DataCenter_Name
input field. Can someone provide guidance on how to fix this?