sajiii sajiii - 9 months ago 72
jQuery Question

Fill dropdown with jquery ajax ASP.NET MVC

i want to get all notifications with signal R and i want to fill drop-down list with all notifications coming from database...i received all notifications but when i display on drop-down...all are not in proper format ..these all are just like a single notification...enter image description here


public ActionResult GetMessages()
MessagesRepository _messageRepository = new MessagesRepository();
return PartialView("_MessagesList", _messageRepository.GetAllMessages());


function getAllMessages()
var tbl = $('#messagesTable');
url: '/Home/GetMessages',
contentType: 'application/html ; charset:utf-8',
type: 'GET',
dataType: 'html'
}).success(function (result) {

text: 'New Notification Available You May Check',
animation_hide: 'custom-hide-animation 0.5s forwards'


}).error(function () {




In your _Message view you should write your code in <table> tag... like this


    @foreach (var item in Model)
                @Html.DisplayFor(modelItem => item.Message)

                @Html.DisplayFor(modelItem => item.EmptyMessage)