Dec 2, 2011, 10:43 PM
9 Posts
topic has been resolvedResolved

How to destroy/terminate xpages partial request?

  • Category: Dojo and Client Side JavaScript
  • Platform: All
  • Release: 8.5.3
  • Role: Developer
  • Tags: destroy terminate partial request
  • Replies: 3
When Browser is waiting to refresh a part of data (eg. using XSP.partialRefreshGet), how to destroy/terminate this request by client side? 
Dec 3, 2011, 8:24 AM
272 Posts
Re: How to destroy/terminate xpages partial request?
Hi,
 
Dojo provides a method to cancel an xhr-Request. The only problem is that XSP won't give you direct access to the underlying xhr-Object; that is why you can not cancel the request via the XSP object directly. Here is a workaround which hijacks Dojo. You have to add this in a script block.
 
var xhrCall = null;

dojo.addOnLoad( function(){
    dojo._xhrPost = dojo.xhrPost;
    dojo._xhrGet = dojo.xhrGet;

    dojo.xhrPost = function( args ){
       xhrCall = dojo._xhrPost( args );
     }

    dojo.xhrGet = function( args ){
        xhrCall = dojo._xhrGet( args );
    }
});

 
Now, you are able to cancel a running partial refresh with a simple
 
xhrCall.cancel();
 
Normally, an error will be raised by the XSP if a refresh is canceled. To solve this you have to add a custom error handler to your refresh, f.e.
 
XSP.partialRefreshGet('id', { onError: function(){} } );
 
Hope this helps
Sven
 
http://blog.hasselba.ch
Dec 6, 2011, 1:13 AM
9 Posts
Re: How to destroy/terminate xpages partial request?
Thanks solution
Dec 14, 2015, 4:32 AM
178 Posts
To solve this you have to add a custom error handler to your refresh, f.e. ??

I would like to use this code in the xsnippet for a responsive standby dialog. But I do not understand how to apply the " To solve this you have to add a custom error handler to your refresh, f.e." suggested solution. Can you provide some guidelines?