Advertisement
flomath

Untitled

Apr 20th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var divs = $('#divs > div'),
  2.     output = $('#output'),
  3.     tarr = [0, 0, 0, 0],
  4.     delay = 100;
  5.  
  6. divs.click(function() {
  7.     $(this).addClass('selected').siblings().removeClass('selected');
  8.     console.log("track!");
  9. });
  10.  
  11. setInterval(function() {
  12.     var idx = divs.filter('.selected').index();
  13.     tarr[idx] = tarr[idx] + delay;
  14.     output.text('Times (in ms): ' + tarr);
  15.     //console.log('Times (in ms): ' + tarr);
  16. }, delay);
  17.  
  18. $(function(){
  19.         $("#test").on("submit", function(event) {
  20.             event.preventDefault();
  21.         console.log('Times (in ms): ' + tarr);
  22.         tarrString = tarr.toString();
  23.            
  24.             $.ajax({
  25.                 url: "next.php",
  26.                 type: "post",
  27.                 data: {tarr: tarrString},
  28.                 dataType: "text",
  29.                 success: function(d) {
  30.                     //alert(d);
  31.                 }
  32.             });
  33.         });
  34.     })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement