gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 04:40:56 24 4
gpt4 key购买 nike

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

Controller ===>>>

 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 () {

});


}

最佳答案

在您的 _Message View 中,您应该在 <table> 中编写代码标签...像这样

_消息==>>

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

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

</td>
</tr>


}

</table>

关于jquery - 使用 jquery ajax ASP.NET MVC 填充下拉列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37978193/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com