timer - How do you add a delay to Jquery text display -


i've researched question pretty thoroughly here , no answers have worked me. displaying text book 1 word @ time in same exact location on screen. trying loop delay x milliseconds, words displayed immediately. fast user sees last word in sentence.

nothing, settimeout, setinterval, waiting ajaxcomplete, etc slows down display of words.

even if use ajaxcomplete , loop words out of ajax, settimeout, setinterval not slow down display of words. frustrating. appreciated in advance!

need keep ajax async - there buttons users pause, skip ahead etc.

function showword(){     $('#thedata').html(word); }  function getthissentence(){     var sentence;     var x;     var str = '';      var surl = "how-data.php?choice=1&book_id=7&chap_num=1&sent_num=1";         x = 0;                                                   $.ajax({             cache:false,             async:true,             url:surl,                datatype:"json",             success: function(data){                 words = data.words.split(' ');                 $.each(words,function() {                     var time = 1500;                     word = words[x];                     temp - word;                     settimeout( function(){ showword() }, time)                         time += 1500;                      x++;                 });              }          });  } 

multiply timeout index staggered delay, , should need

function getthissentence(){     $.ajax({         url      : "how-data.php?choice=1&book_id=7&chap_num=1&sent_num=1",            datatype : "json",         success  : function(data){             $.each(data.words.split(' '), function(index, word) {                 settimeout(function(){                       $('#thedata').html(word);                 }, 1500*index);             });         }      }); } 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -