Passing data between two hooks in separate HTML requests

It’s not possible to pass data from one HTTP request to another one on the fly. Once the script is finished, the data will be discarded.

What you can do is to store the data in a transient, and then retrieve it later. Here’s a simple example using set_transient():

set_transient( 'my_transient', $data, 1 * HOUR_IN_SECONDS );

Then, you can retrieve it using get_transient():

get_transient( 'my_transient' );