如何在MVC 4中没有完整页面加载的情况下加载数据 [英] How to load the data without full page load in MVC 4

查看:82
本文介绍了如何在MVC 4中没有完整页面加载的情况下加载数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个员工列表,在那个列表编辑按钮就在那里。单击编辑按钮后,我在模型弹出窗口中打开了编辑员工部分视图。当我单击弹出数据中的保存按钮时,会更新并重定向到操作员工列表。但这会导致整页加载。如何在没有完整页面刷新的情况下加载更新的数据。

I have a Employee list,in that list edit button is there. When the edit button is clicked i have opened a Edit employee partial view in model popup. When i click the save button in the popup data is updated and i redirected to the action employee list. But this causes full page load. How can I load updated data without full page refresh.

推荐答案

该方法称为ajax。你可能找不到一个简单的解决方案,但它很简单:

当你点击保存时,你不应该发布整个页面,你应该准备调用一个javascript函数执行以下操作: br />
1)启动对将在数据存储中执行更新的操作的ajax调用。该操作不应该返回列表页面视图,而是返回带有操作结果的json对象,以及您考虑的任何其他信息。

2)如果操作成功,它应该在客户端更新列表关于它传递给服务器端的数据

3)如果有任何错误,它应该弹出一个正确的消息



检查: http://mscodingblog.blogspot.fr/2013/04/怎么做-ajax-in-aspnet-mvc4.html [ ^ ]
The approach is called ajax. You will probably not find a drop-in solution, but it is quite simple:
When you hit save, you should not post the whole page, you should prepare call a javascript function doing the following:
1) Launch an ajax call to the action that will perform the update in the data store. The action should not return the list page view, but a json object with the operation result, and any other information you consider.
2) If the operation succeeds, it should update the list on client side based on the data it passed to the server side
3) In case of any error, it should popup a proper message

Check this: http://mscodingblog.blogspot.fr/2013/04/how-to-do-ajax-in-aspnet-mvc4.html[^]


这篇关于如何在MVC 4中没有完整页面加载的情况下加载数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆