Search code examples
javascriptgoogle-app-maker

AppMaker Return value from server side to client side


I have on a AppMaker page a button who execute a function on the client side

function showall(){
  app.pages.ProjectComposant.children.Html1.html = google.script.run.showhtml();
}

and the function on the server side is

function showhtml(){
  return "<p>test</p>";
}

but the server not return the string. I have try to use the withSuccessHandler() but there is no onSucess handler on the client side script

There is another way to get a returned value from the server ? tanks


Solution

  • in server side

    function showhtml(){
      return JSON.Stringify("<p>test</p>");
    }
    

    in client side

        function showall(){
    
        google.script.run.withSuccessHandler(
    function(returned_result){ 
    app.pages.ProjectComposant.children.Html1.html = JSON.Parse(returned_result); 
    })
        .showhtml();
        }