I have a json which contains list of serialized objects. And I want to walk this json and show messages from it one message per 2 seconds and then stop. I did it this way:
$.ajax({
type: 'GET',
url: basename+'/getUnprocessedList/123',
dataType: 'jsonp',
success: function (data) {
for(var i=0, keys=Object.keys(data), l=keys.length; i<l; i++) {
console.log('hit '+i);
setInterval(processMessage(data[i]),2000);
}}
});
But nothing working there, setInterval just ignored, all messages displayed at once, like no any timeout. I tried $.each, setTimeout, nothing works. What's wrong there?