jBoive
jBoive

Reputation: 1299

XPages: Get the contents of a - this._partialRefresh AJAX call?

I'm doing a partialrefresh of an XPage (Domino 8.5.1) but need to get the contents of the response.

The reason is that IE8 seems to (sometimes) have an issue with partial refreshed HTML not showing. I can see that the response is correct but the DOM isn't updated.

There's an easy fix for this:

div.innerHTML = div.innerHTML

But for me to apply this I need the content so I can insert it in the first place.

So, is it possible to get the returned HTML from a partialRefresh? Or is there another way to solve this?

Upvotes: 0

Views: 1319

Answers (2)

Sven Hasselbach
Sven Hasselbach

Reputation: 10485

To hijack a partial refresh you can add this CSJS code:

// --- hijack dojo XHR calls
dojo._xhr = dojo.xhr; 
var loadOld;

function hijacked( response, ioArgs ){
   alert( response ); // change code here to do whatever you want. // 
   loadOld( response, ioArgs ); // call the original function 
}

dojo.xhr = function( mode, args, bool ){
    loadOld = args["load"];
    args["load"] = hijacked;
    dojo._xhr( mode, args, bool );
}

Just change the function "hijacked" to fullify your requirements.

Hope this helps

Sven

Edit: The method "hijacked" is executed BEFORE the changes to the DOM will be applied (and before OnComplete event)

Upvotes: 2

Tim Tripcony
Tim Tripcony

Reputation: 8086

You can trigger a partial refresh as a client-side event:

XSP.partialRefreshGet("#{id:targetId}", {
    onComplete: function(responseData) {
        // examine the response content
    }
});

The onComplete function will be passed the response from the server, and you can parse or otherwise respond to the data within that function.

Upvotes: 8

Related Questions