I think what you are looking for is an "XAGent" that will output html to the browser after an event.
On your button add the code to the onClick event to load the target XAgent
On the target XPage, set it's render property to false, and in the afterRenderResponse event add the following code. Where I have the Hello World output you can compute whatever output you want.
var extCont = facesContext.getExternalContext();
// The Faces Context Response Writer is similar to the Lotuscript print statement
// and the Java printwriter object to produce output to the browser.
// There is also a getResposneStream() for producing binary output.
var pageOutput = facesContext.getResponseWriter();
// The servlet's response object provides control to the response object.
var pageResponse = extCont.getResponse();
// The content type has to be set to the output MIME type. In this case HTML.
// Additional methods of the response object can be set. The following keeps the content from being cached.
// Use the writer object to produce all of the output. The following is a simple HTML Page.
// End and close the writer object.
// Terminate the request processing lifecycle.