Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I think the solution you referenced will work for you. You just need to have your initial controller action return right away with the "please wait message", then have the AJAX call do the actual retrieval of the contents based on your processing. If the request really takes 5-10 seconds you may also need to adjust the timeout value on the AJAX request so that it is able to complete. I don't know what the default timeout is but is may be less than what you need.</p> <p><strong>EDIT</strong> Example:</p> <p>View code:</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready( function() { $.ajax({ type: "POST", url: '&lt;$= Url.Action("GetSlowData","Controller") %&gt;', data: 'id=&lt;%= ViewData["modelID"] %&gt;', timeout: 15000, // wait upto 15 secs success: function(content){ $("#container").html(content); } }); }); &lt;/script&gt; ... &lt;div id="#container"&gt; Please wait while I retrieve the data. &lt;/div&gt; </code></pre> <p>Controller</p> <pre><code>public ActionResult ViewMyData( int id ) { ViewData["modelID"] = id; return View(); } [AcceptVerbs( HttpVerbs.Post )] public ActionResult GetSlowData( int id ) { var model = ... do what you need to do to get the model... return PartialView(model); } </code></pre> <p>You'll also need a partial view (ViewUserControl) that takes your model and renders the view of the model. Note that this isn't complete -- you'll need to add error handling, you may want to consider what happens if javascript isn't enabled, ... </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload