Skip to content Skip to sidebar Skip to footer

Server Side Code Not Working In Google App Script

Hi I am trying to do a simple thing: 1) create two links in my HTML page 2) When user clicks on link1- I want it to call a server side function that displays 'Hello World'. But whe

Solution 1:

You are not seeing "Hello World" displayed anywhere because you have not written any code to display it!

All your code does is run server-side doSomething() function, which returns text output. You need to add a success handler to your google.script.run and specify a callback function to run after the server-side function returns successfully, e.g:

google.script.run.withSuccessHandler(processResult).doSomething();

Then write a processResult() javascript function that accepts server return as first argument and does whatever you need to do with it, i.e.:

functionprocessResult(data) {
  console.log(data);
}

See google.script.run reference and HTML Service success handlers reference for more details.

Post a Comment for "Server Side Code Not Working In Google App Script"