如果要加载页面,然后通过ajax加载部分视图,则可以创建一个
ActionMethod执行以下操作的对象:
public ActionResult Create(){ var model = new MyModel(); if (Request.IsAjaxRequest()) { return PartialView( "_Partial", model.PartialModel ); } else { return View( model ); } }然后在您的页面中执行以下操作:
$(function(){ $(document).ajaxStart(function () { //show a progress modal of your choosing showProgressModal('loading'); }); $(document).ajaxStop(function () { //hide it hideProgressModal(); }); $.ajax({ url: '/controller/create', dataType: 'html', success: function(data) { $('#myPartialContainer').html(data); } });});


