you need to detect in advance that javascript is enabled. say a sniffer page, that redirects with javascript. then replace the RenderAction, with a spinning gif of your choice. you must also be sure none of the actions use session.
as I said remove the partial view from the view, then change the actions that $.load() calls to return partial views. be sure to turn off session, or they will processed one at a time, and the page will take longer.
bruce (sqlwork.com)
Marked as answer by CareerChange on Jan 29, 2013 09:09 PM
CareerChange
Member
43 Points
180 Posts
load partial content async in parallel
Jan 28, 2013 11:12 AM|LINK
Hi
Can anyone help with this, I have 4 sections on the page that display partial views with the data been pulled from a database.
I want to load the data async using jquery or ajax if javascript is enabled, if not just load the data.
I also want to load the data in parallel for a quicker page load instead of 1 then 2 then 3 etc.
I have the following so far below, but i do not know how to load them all together, also how do I add a spinning disk while each section is loading.
<div id="dvAsyncDest"> @{Html.RenderAction("pvDestination","DestinationReport", true);} </div> <div id="dvAsyncCurr"> @{Html.RenderAction("pvCurrency", "Currency", true);} </div> <div id="dvAsyncLatest"> @{Html.RenderAction("pvLatest","TravelNews", true);} </div> <div id="dvAsyncDirectory"> @{Html.RenderAction("pvDirectory","TouristDirectory", true);} </div> $('#dvAsyncDest').load @Url.Action("pvDestination","DestinationReport"); $('#dvAsyncCurr').load @Url.Action("pvCurrency", "Currency"); $('#dvAsyncLatest').load @Url.Action("pvLatest","TravelNews"); $('#dvAsyncDirectory').load @Url.Action("pvDirectory","TouristDirectory");Thanks for any help
George
bruce (sqlwo...
All-Star
36836 Points
5443 Posts
Re: load partial content async in parallel
Jan 28, 2013 03:03 PM|LINK
you need to detect in advance that javascript is enabled. say a sniffer page, that redirects with javascript. then replace the RenderAction, with a spinning gif of your choice. you must also be sure none of the actions use session.
CareerChange
Member
43 Points
180 Posts
Re: load partial content async in parallel
Jan 28, 2013 03:37 PM|LINK
bruce (sqlwo...
All-Star
36836 Points
5443 Posts
Re: load partial content async in parallel
Jan 29, 2013 04:15 AM|LINK
as I said remove the partial view from the view, then change the actions that $.load() calls to return partial views. be sure to turn off session, or they will processed one at a time, and the page will take longer.