Sure, you can do it that way too. I made it so all methods are easily replaceable. The query_database() method returns an AoA of data, then the build_ajax_table() wraps the rows of the AoA in 'tr' tags and for each column in the row, cleans the XML and wraps it into 'td' tags. You can make a method that does both things at once, and just feed the results to send_ajax_response() without calling either of the built-ins.
I am thinking of something more generic for "drill-downs" - basically make it so you can specify any column as a drill-down column, which will automatically create an href around the values in the column that when clicked will do a WHERE col = val (e.g. you click on "Africa" in the "region" column and that will "drill-down" to WHERE region = 'Africa').