call ajaxRequest in pageUnLoad

7 posts, 0 answers
  1. Pranav Dagaonkar
    Pranav Dagaonkar avatar
    6 posts
    Member since:
    Jan 2008

    Posted 26 Sep 2008 Link to this post

    I try to make an ajax call (RadAjaxManager.ajaxRequest()) in pageUnLoad event handler. My goal is to save some data on the page before the page gets unloaded either by clicking an out-going url or by closing the browser window. However, I found after calling ajaxRequest(), the page cannot be unloaded. In other words, if I click a link, the new page will never get loaded. The following is the function I called in pageUnload(). Has anyone done something like this before? Any solutions? Thanks in advance.

     function SaveOnExit()  
                {                                 
                    var ajaxManager = $find("<%= ram.ClientID %>");               
                    ajaxManager.ajaxRequest();       
                    
                }         
  2. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 29 Sep 2008 Link to this post

    Hi Pranav,

    The question set forth has been addressed in the support ticket that you opened on the matter. To avoid duplicate posts, we can continue our communication there.

    Kind regards,
    Yavor
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mostafa Anoosheh
    Mostafa Anoosheh avatar
    462 posts
    Member since:
    Nov 2005

    Posted 06 Oct 2008 Link to this post

    Hi,
    Please let me know if you find any solution to solve this issue?

    Best regards
    Mostafa Anoosheh
  5. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 07 Oct 2008 Link to this post

    Hello Mostafa,

    Attached to this message, is a small application, which was furnished as a possible approach in this setup.
    I hope it helps.

    Sincerely yours,
    Yavor
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. Pranav Dagaonkar
    Pranav Dagaonkar avatar
    6 posts
    Member since:
    Jan 2008

    Posted 06 Nov 2008 Link to this post

    I'm still having problem with reliably calling ajaxRequest() during page unload. Sometimes the call could get through and the other time it couldn’t (especailly with IE6 SP3). Is there a way that I can make a synchronous ajax call? Therefore, I can make sure the call is completed before the page gets unload.

    Here is my code, I tried to call SaveOnExit() inside PageUnload(), Unload() and BeforeUnload(). But none of them are as reliably as I'd like. I event added some delay, but it still doesn't help much. It seems to me if I could make a synchronous ajax call so the page won't get unloaded until the response is coming back is the only way.

    function SaveOnExit()
    {
    try{
    var ajaxManager = $find("<%= ram.ClientID %>");
    ajaxManager.ajaxRequest();
    }
    catch(e){
    alert(e);
    }
    }

  7. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 07 Nov 2008 Link to this post

    Hello Pranav,

    Another option in this case would be to use a RadWindow, and use the onclose client side handler, to handle this setup.

    All the best,
    Yavor
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  8. HHalim
    HHalim avatar
    69 posts
    Member since:
    Aug 2005

    Posted 10 Nov 2008 Link to this post

    I like to add that calling ajax requests within unload event may used up the internet connection within IE.

    IE7 has 2 maximum live connections, when an ajax calls is interrupted, IE does not know how to close the connection, this results in a hang after 2 ajax calls within unload event. It is a serious issue that Firefox doesn't have. User has to either wait until the connection times out or force IE to close.

    The only reliable solution is synchronous call within unload event.

    Summary of the issue from MS support:
    "It looks like IE will not send new requests to the same domain when the hang happens. What I can guess so far is, IE somehow doesn't know the connection should be closed if a user manually interrupts the AJAX request by closing the tab. By default, as you may know, IE only allows two subsequent connections to one domain. I've contacted our development team for a confirmation about this issue. They may need some time to come to a final conclusion. I'll follow up and update here. "
    
    Here are links that discusses the issue:
    http://bytes.com/forum/thread643080.html (contains a demo page that demonstrate the issue)
    http://www.eggheadcafe.com/software/aspnet/33118270/ajax-and-ie-crash.aspx (Microsoft support replying to a user with the issue)

    I hope this helps.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017