zaterdag 28 december 2019

Webapp: data from client to server to client with GAS

Finally I understand how to send data from a client to a server and get  (other) data returned from the server at the same time.

At the server side:


function fromAndToClient(dataFromClient){

//do something with dataFromClient

return dataToClient
}

At the client side:


<script>

document.getElementById("button").addEventListener("click",doSomething);

function doSomething(){

var dataFromClient = document.getElementById("idElement").value;
  
google.script.run.withSuccessHandler(fromServer).fromAndToClient(dataFromClient);
    
}
  
  
function fromServer(dataToClient){

  // do something with dataToClient

}
  
</script>

Geen opmerkingen:

Een reactie posten