I'm try to pass multiple parameters in a get JSON result but that code doesn't work, it is working if I only pass 1 parameter but not if I pass multiple. Maybe my syntax is wrong? Help please
VIEW
$(document).ready(function () {
$("#ddltype").change(function () {
var id = $(this).val();
$("#subject").change(function () {
var id1 = $(this).val();
$("#section").change(function () {
var id2 = $(this).val();
$.getJSON("../Employee/getWeightedAverage", { id: id, subject:id1, section:id2 }, function (Ave) {
$("#av").val(Ave);
});
});
});
});
});
@Html.EditorFor(model => model.subject_id, new { id = "subject" })
@Html.EditorFor(model => model.section_id, new { id = "section" })
<div class="editor-label">
@Html.LabelFor(model => model.g_type)
</div>
<div class="editor-label">
@Html.DropDownListFor(model => model.g_type, new List<SelectListItem>{
new SelectListItem {Value = "1", Text = "Written Work"},
new SelectListItem {Value = "2", Text = "Performance Task"},
new SelectListItem {Value = "3", Text = "Quarterly Assesment"},
},"Select Type", new { id = "ddltype" })
@Html.ValidationMessageFor(model => model.g_type)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.weighted_percent)
</div>
<div class="editor-field">
@Html.TextBoxFor(model => model.weighted_percent, new { id = "av" })
@Html.ValidationMessageFor(model => model.weighted_percent)
</div>
JSON
public JsonResult getWeightedAverage(string id, string subject,string section)
{
string Ave = "40" + subject + section;
return Json(Ave, JsonRequestBehavior.AllowGet);
}