i create the script call function in mvc controller , it's working good in visual studio, but when i converted to IIS website , all website working good else casecading dropdownlist ,,,
my code (
=========================================================
function
public ActionResult FillDept(string level)
{
var depart = db.Departments.Where(c => c.LevelId == level);
return Json(depart, JsonRequestBehavior.AllowGet);
}
script in html view
<script>
function FillDept() {
var levelId = $('#Level').val();
$.ajax({
url: '/Trainees/FillDept',
type: "GET",
dataType: "JSON",
data: { Level: levelId },
success: function (depart) {
$("#Department").html("");
$.each(depart, function (i, department) {
$("#Department").append(
$('<option></option>').val(department.DeptId).html(department.DeptName))
});
}
});
}
</script>
dropdwonlist
@Html.LabelFor(m => m.Level, new { @class = "control-label col-md-1" })
<div class="col-md-3 jumbotron">
@Html.DropDownListFor(m => m.Level,
new SelectList(ViewBag.LevelList, "LevelId", "LevelName"),
"level",
new { @class = "form-control", @onchange = "FillDept()" })
@Html.ValidationMessageFor(m => m.Level, "", new { @class = "text-danger" })
</div>
@Html.LabelFor(m => m.Department, new { @class = "control-label col-md-1" })
<div class="col-md-3 jumbotron">
@Html.DropDownListFor(m => m.Department,
new SelectList(Enumerable.Empty<SelectListItem>(), "DeptId", "DeptName"),
"department", new { @class = "form-control" })
@Html.ValidationMessageFor(m => m.Department, "", new { @class = "text-danger" })
</div>
)
What I have tried:
Hi there , i need to help please ..
asp.net MVC code first