View
jquery
function getRelation() {
$.ajax
({
url: "@(Url.Action("FillRoles", "Roles"))",
data: {},
success: function (result) {
var html = "";
html += "<option>Select</option>";
for (var i = 0; i < result.length; i++) {
html += "<option value=" + result[i].ID + ">" + result[i].Description + "</option>";
}
$("#ddlAddRoles").html(html);
}
});
}
html
<div class="col-sm-4 tb-font">
<form>
<label class="col-form-label">Relation</label>
<select id="ddlAddRoles" name="ddlAddRoles" class="form-control dropdown" style="margin-bottom:2px"></select>
</form>
</div>
Explanation
This function will receive data returned from FillRoles() Method of Roles Controller and populate the append the ddlAddRoles dropdown list in HTML
Leave a comment