RadAjax for ASP.NET AJAX

Dropped Ajax requests from child window Send comments on this topic.
Controls > RadAjax > General Troubleshooting > Dropped Ajax requests from child window

Glossary Item Box

In Internet Explorer, windows opened using window.open from another window, exist in the same thread as the parent window. This is not true for Mozilla and Safari as there all child windows are opened in different threads. Thus when you initiate an ajax request in the child window and close this window it will be aborted in Mozilla, because closing it you actually destroy the thread which is running the ajax request. This workd in IE, because the child window runs in the same thread as the parent and it does not destroy it when it closes.

To resolve this issue you need to create ajax requests in the context of the parent window and apply a slight timeout on it:

 

JavaScript Copy Code
<script type="text/javascript">
           
function OnClickHandler()
           {
               
var thisWindow = window;
               var parentWindow
= window.opener;
               parentWindow.setTimeout(function() { UpdateData(thisWindow, parentWindow) } , 0);
           }
            
           
//this is executed in the parent window context
           
function UpdateData(childWindow, parentWindow)  
           {
               
var radAjaxManagerObject = parentWindow["RadAjaxManager1"];
               radAjaxManagerObject.AjaxRequest(params);
               childWindow.close();
           }
</script>  
 

The same goes when using our Telerik RadWindow control. You still need to force the execution in the parentWindow, as otherwise the request will be canceled, once the window is closed:

 
JavaScript Copy Code
<script type="text/javascript">
 
//This code is mandatory if any interaction with the "parent" RadWindow object is needed
 
function GetRadWindow()
 {
  
var oWindow = null;
  
if (window.radWindow) oWindow = window.radWindow;
  
else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
  
return oWindow;
 }
 
function Cancel_Clicked()
 {
  
GetRadWindow().Close();
 }
 
function DoParentCallback()
 {
           
var parentWindow = window.parent;
           parentWindow.setTimeout(function()
   {
    var radAjaxManagerObject
= parentWindow["RadAjaxManager1"];
    radAjaxManagerObject.AjaxRequest();
   } , 0);
     Cancel_Clicked();
 }
</script>

Note that we use setTimeout to force execution in the parentWindow's context as it will not get closed. Another thing to keep in mind is that one should not reference the child window in your setTimeout-invoked code as it might have already been destroyed.