Making a Simple Ajax call to controller in mvc to load data into dropdownlist


 Public Function Get_Plant() As ActionResult
 Dim plantrole As New PlantRequestParam
 Dim rinfo = New Common.ResultInfo
 rinfo = iPlant.GetAllActiveList(plantrole)
 Return Json(rinfo)
End Function


var AjaxUrl = "../Home/Get_Plant";
 type: 'POST',
 url: AjaxUrl,
 contentType: 'application/json; charset=utf-8',
 success: function (data) {
 if (data.Status == true) {
 var taglist = data.Data;

$.each(taglist, function (index, value) {
 var opt = new Option(value.Name, value.Id);
 $(opt).attr('data-code', value.Code);

error: function (ex) {
 Message: AjaxUrl + "
" + ex.status + " - " + $(ex.responseText).filter('title').text(),
 Status: false

To load into HTML li tag:

$.each(taglist, function (index, value) {
 list.append(' + value.Code + ');



jhep-coursera-course4.pngHTML, CSS, and Javascript for Web Developers



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.