I have this code:
index.html
<!DOCTYPE html>
<html>
<div>
<form id="email_subscribe">
<input type="email" name="email" id="email" placeholder="Enter your email">
<input type="submit" value="Subscribe">
</form>
<span id="thank_you" hidden="true">Thank you!</span>
</div>
<?!= HtmlService.createHtmlOutputFromFile('CSS').getContent(); ?>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
$( document ).ready(function() {
$( "#email_subscribe" ).submit(function() {
google.script.run.withSuccessHandler(function(ret){
$("#email_subscribe").slideUp();
$( "#thank_you" ).show("slow");
console.log(ret);
}).addEmail(this); //"this" is the form element
});
});
</script>
</html>
and this one:
Code.gs
function doGet() {
var html = HtmlService.createTemplateFromFile('index').evaluate()
.setTitle("Web App 2").setSandboxMode(HtmlService.SandboxMode.NATIVE);
return html;
}
function addEmail(form){
Logger.log(form.email);
return 200;
}
The "Thank you message" is not showing up upon submitting the form. Can you please tell me what am I doing wrong. Thank you.