Success and failure handlers for Google Apps Web Apps. Place this in HTML for Google Apps HTML service.
<script>
function onSuccess(numUnread) {
alert('You have ' + numUnread + ' messages');
}
function onFailure(error) {
alert(error.message);
}
google.script.run.withSuccessHandler(onSuccess).withFailureHandler(onFailure).getUnreadEmails();
google.script.run.doSomething();
</script>