MVC Web 应用程序中的操作调用和 javascript 调用
如何在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要为该操作实现一个控制器。 Javascript [ajax] 调用是一个简单的 http 请求,您需要以 json 或 xml 形式应答响应。 Google 搜索 java 的 json 序列化器,有很多存在。
我建议您使用 jquery 和 google-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.