My script is as follows which should replay mouse image inside a div but settimeout is not working and there is no error in console also:
function play(data, value) {
var data = data;
function run() {
var nowTime;
var newdata = data.splice(0, 1); // after splice, data will be auto updated
if (newdata.length == 1) {
nowTime = newdata[0][6];
var timer = setTimeout(function() {
if (newdata[0][3] == '14') {
replay(newdata[0][0], newdata[0][1]);
}
preTime = nowTime;
// continue run next replay
run();
}, nowTime - preTime);
}
}
run();
}
Please help me. How to solve this issue.
thanks in advance