在剃须刀页面上添加Ajax处理程序
我熟悉传统mypage.cshtml
和mypage.cshtml.cs
使用ongetAsync
和onpostasync 方法,但是,如何将另一个处理程序添加到模型页面中,可以使用JavaScript调用,而无需进行完整的表单帖子?
I am familiar with the traditional MyPage.cshtml
and MyPage.cshtml.cs
files with OnGetAsync
and OnPostAsync
methods, but how do I add another handler to the model page that I can call with javascript without doing a full form post?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这种情况下,我们将JSONRESULT返回以更容易被JavaScript消耗(但此示例对结果无济于事)。
请注意,JavaScript中引用的处理程序是
Waffles
而不是OnpostWafflesAsync
,相关参考:
In this case, we return a JsonResult to be more easily consumable by the javascript (but this example does nothing with the result).
Note that the handler referenced in the javascript is
Waffles
instead ofOnPostWafflesAsync
, relatedReferences: