The built-in google.script.run does this for us.
You can think that the Apps Script platform gets the return value of your server-side function JSON.stringify it and then JSON.parse on the client-side normally. And since withSuccessHandler receives you return function, running it and passing a parameter is easy. As shown by Frits.
Here is what the withSuccessHandler documentation says:
Because client-side code continues to the next line without waiting
for a server call to complete, the google.script API allows you to
specify another client-side function to run when the server responds.
If the server function returns a value, the API passes the value to
the new function as a parameter.
By the way, the code example worked just fine for me. Have you had any problems? This is the code I used (plus the example exact html file, which I called "page"):
function doGet() {
return HtmlService.createHtmlOutputFromFile('page');
}
function getLotsOfThings() {
return [1,2,3];
}
getLotsOfThings()gets called, but not howshowThings()is ever sentthings.