Ok, so this is how I did it, and it’s not an awful hack.
So my problem was passing values (in this case, query args) to a callback function from a instance of a class that was created BEFORE the query args existed.
The transient approach worked but can break anytime.
So when the function query value exists, I simply assigned it as the value of an hidden input field that belongs to the form that holds the filters, namely:
echo( '<input type="hidden" name="wp-query-args" value="' . $encoded_query_args . '">' );
At this stage the $encoded_query_args contains the serialised query using wp_json_encode.
When the AJAX call is made, it sends the form data serialised to the callback function using POST:
function requestSetup($,formId,ajaxURL) {
$('#saf_submit').on('click', function(){
var filter = $(formId);
$.ajax({
url:ajaxURL,
data:filter.serialize(), // form data
...
The callback can then received this information and decode query args into its original form:
$query_args = self::decode_query_args( $_POST['wp-query'] );
No transients, no limits, it simply works! 🙂