ASP.NET MVC - Ajaxified RenderAction
我对 RenderAction() 函数的作用感到满意。但是,我想在部分渲染的操作中对数据的加载和存储进行ajaxify,以便一切都发生在一个页面中。
想象一下以下情况:我有一个文章详细信息视图,其中文章内容下方有一个“添加评论”链接。单击后,帖子内容下方会出现一个评论表单。用户应该能够填充评论框并发送数据,而无需刷新整个视图,而只需刷新部分呈现的操作。此外,视图必须提供在同一会话中添加的多个注释(对 RenderAction() 的多个 AJAX 调用);
实现这一目标的最佳方法是什么?
I am happy with what the RenderAction() function does. However, I'd like to ajaxify the loading and storing of data in the partially rendered action, so that everything happens in one page.
Imagine the following case: I have an article details view where there's an "Add comment" link beneath the content of the article. When it's clicked, a comment form would appear beneath the content of the post. The user should be able to fill the comment box, and send the data without refreshing the whole view, just the partially rendered action. Also the view must provide for several comments to be added in the same session (several AJAX calls to RenderAction());
Which is the best way to achieve that ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
操作:
视图:
JavaScript:
这是基础知识。您可以根据需要将其变得复杂。
Action:
View:
JavaScript:
That's the basics. You can make this as complicated as you like.