【发布时间】:2021-04-28 07:14:29
【问题描述】:
我有不同的<a> 标签,通常使用asp-route="" 将参数传递给操作。现在我想使用 AJAX 来做到这一点。当页面加载时,每个标签都应该传递来自模型chats 的ID。 (asp-route-ChatID="@Model.ID")。
如何在 AJAX 中实现这一点并传递该参数?我尝试使用Data-ajax-update 和Data-ajax-url,但这些选项甚至在 Intellisense 中都不可用。这是我要调用的方法
public IActionResult Chat(string ChatID)
{
Chats userchats=new Chats(); // a class that holds chats
//selecting data from the database......
return View(userchats);//returns view with the model
}
这是被点击的<a>标签,它需要传递来自模型的特定ID
<a > View Chat </a>
这里是<div>,需要根据点击的<a>进行更新
<div id="UpdateThis"> <!--show data that comes from the method ajax calls--> </div>
如何在此处使用标签助手或任何其他方式实现 ajax?
【问题讨论】:
标签: ajax asp.net-core .net-core asp.net-core-mvc