<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script> $(function() { google.script.run .withSuccessHandler(function(dp) { f(dp); }) .withFailureHandler(function(msg) {}) .step() }); function f(dp) { var timer; var delay = 1000; s=1; var loop = function(){ s=s+1; if(s>10)s=1; str=dp[s][1]; $("#results").html(str); clearTimeout(timer); timer = setTimeout(loop,delay); } loop(); } </script>