I've developed a Google Sheets add-on that utilizes a modal dialog for the user interface. I encountered an issue with the success handler not running as expected, so I created a basic test interface to troubleshoot the problem.
After the server-side function completes its task, the success handler function should execute. Instead, I keep receiving an error message stating "Untaught TypeError: a is not a function". Interestingly, I can manually initiate the desired function by clicking a button added purely for demonstration purposes. See the code snippet below:
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<script>
function success(){
document.getElementById("waitMessage").innerHTML = "TEST";
}
function testFunc(){
google.script.run.withSuccessHandler("success").serverSideFunc();
}
</script>
</head>
<body>
<p>
Click the button to close the window
</p>
<form>
//Doesn't work
<input type="button" name="test" value="Server-side test" onclick="testFunc()">
//Works
<input type="button" name="test-client" value="Client-side test" onclick="success()">
</form>
<div id="waitMessage">
<p></p>
</div>
</body>
</html>
.gs script file below:
function serverSideFunc(){
Logger.log("");
}
From the given code, it's evident that the .gs script consists of a dummy function aimed at triggering the success handler.
Could anyone shed some light on what might be causing this issue? Perhaps I overlooked something simple?