MVC Web 应用程序中的操作调用和 javascript 调用

发布于 2024-08-23 13:44:29 字数 131 浏览 1 评论 0原文

如何在 MVC 中调用服务器端代码和 javascript? 我们在每个页面上都有一个关闭按钮。 单击关闭按钮时,应该调用控制器操作,并且浏览器应该关闭。 此外,如果用户单击浏览器关闭,则应在关闭之前调用相同的控制器操作。 以前有人做过类似的事情吗

How do you call a server side code and javascript in MVC?
We are having a close button on every page.
on click of close button there should be a call to controller action and the browser should close.
Also if the user clicks the browser close the same controller action should be called before closing.
Have anyone done similar stuff before

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

听不够的曲调 2024-08-30 13:44:29

您需要为该操作实现一个控制器。 Javascript [ajax] 调用是一个简单的 http 请求,您需要以 json 或 xml 形式应答响应。 Google 搜索 java 的 json 序列化器,有很多存在。

我建议您使用 jquerygoogle-json 为此。

You need to implement an controller for that action. Javascript [ajax] call is a simple http-request, and you need to answer response as a json or xml. Google for an json serializer for java, there are many exists.

I can recommend you use jquery and google-json for this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文