When my page loads up, I need to immediately initiate a a data pull in one of the page's user controls for it to populate some search results that display in a grid in that user control. The query to pull those search results can take quite a bit of time (8-10 seconds).
My goal is to make an Ajax request to only update the part of the page containing the user control so that the user can freely interact with other elements on the page while the expensive user control loads it's own data by itself.
In my current approach, the user cannot interact with any elements on the page while that control is loading. When they click on a button for example elsewhere on the page, the Page_Load() for the button click's postback is not reached until the long-running ajax request is finished. It seems that the other Ajax requests are waiting in line behind the long running one.
Here's my approach (Telerik Controls Used for Ajax):
I have a RadAjaxPanel that has a hidden button that will cause the Ajax postback. This button is clicked via Javascript when the page loads. In the click handler for the button there is code to load the user control into the ContentPlaceHolderControl and load the control's data
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="LoadingPanel1">
<asp:PlaceHolder runat="server" ID="PlaceHolderControl">
<!-- user control loaded here -->
<telerik:RadButton ID="btnRADAjax" runat="server" Style="visibility: hidden;"></telerik:RadButton>
</asp:PlaceHolder>
The Javascript that invokes button to do the Ajax PostBack:
function DoAjaxPostBack() {
var interval = setInterval(function()
{
if(document.readyState === 'complete')
{
var argmnt='';
var ajaxManager = $find("<%=RadAjaxManager.GetCurrent(Page).ClientID %>");
ajaxManager.ajaxRequestWithTarget('<%= btnRADAjax.UniqueID %>', argmnt);
clearInterval(interval);
}
},100)
}
On pageLoad:
If Not IsPostBack Then
RadScriptManager.RegisterStartupScript(Page, Page.GetType(), "1", "DoAjaxPostBack('');", True)
End If
Is this a sound approach and there is just no way to get the Ajax Requests from blocking each other? Or is there another approach to get the long-running request to run separately in it's own world without it interfering with the responsiveness of the page it lives on? I'm considering trying an IFrame.
Thanks!