好吧,讓我們給你一些指導,我將在jQuery中展示一些代碼,因爲它很容易。我們走吧。
的Html
<div id="SomeContent"> </div>
在你看來
$(function(){ // this runs on on page load
LoadData('#SomeContent', @Url.Action("ActionName","ControllerName"));
});
在JavaScript庫文件
function LoadData(target, url){
$.ajax({
beforeSend: startAnimation(target),
url : url,
success : function(result){ $(target).html(result); },
complete : stopAnimation(target)
});
}
function startAnimation(target){
//..add a loading image on top of the target
}
function stopAnimation(target){
// remove the animation gif or stop the spinning, etc.
}
你的服務器端代碼
public ActionResult ActionName() {
... do things to get your model populated ...
return PartialView("SomeView", yourmodel);
}
個
更多的想法:
感謝您的詳細解釋。 – Maheep