Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用jquery ajax ASP.NET MVC填充下拉列表_Jquery_Asp.net_Ajax_Asp.net Mvc - Fatal编程技术网

使用jquery ajax ASP.NET MVC填充下拉列表

使用jquery ajax ASP.NET MVC填充下拉列表,jquery,asp.net,ajax,asp.net-mvc,Jquery,Asp.net,Ajax,Asp.net Mvc,我想用信号R获取所有通知,我想用来自数据库的所有通知填充下拉列表…我收到了所有通知,但当我在下拉列表中显示时…所有通知的格式都不正确..这些都像一个通知 控制器===>>> public ActionResult GetMessages() { MessagesRepository _messageRepository = new MessagesRepository(); return PartialView("_Messages

我想用信号R获取所有通知,我想用来自数据库的所有通知填充下拉列表…我收到了所有通知,但当我在下拉列表中显示时…所有通知的格式都不正确..这些都像一个通知

控制器===>>>

 public ActionResult GetMessages()
        {
           MessagesRepository _messageRepository = new MessagesRepository();
            return PartialView("_MessagesList", _messageRepository.GetAllMessages());
        } 
视图==>>>

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

                       $.notiny({
                           text: 'New Notification Available You May Check',
                           animation_hide: 'custom-hide-animation 0.5s forwards'
                       });

                       tbl.empty().append(result);


                   }).error(function () {

                   });


               }

在您的_消息视图中,您应该在
标记中编写代码。。。像这样

_消息==>>

<table>
    @foreach (var item in Model)
    {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.Message)

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

            </td>
        </tr>


    }

</table>

@foreach(模型中的var项目)
{
@DisplayFor(modelItem=>item.Message)
@DisplayFor(modelItem=>item.EmptyMessage)
}

那么
\u消息列表部分返回的是什么呢?