var DataArrayComments = new Array; do { $.getJSON(url, function(response) { console.log(response.comments); Array.prototype.push.apply(DataArrayComments, response.comments.data); if(url) url = response.comments.paging.next; else break; }).fail(function(data){ response = JSON.parse(data.responseText); alert('Error: ' + response.error.message); clearInterval(shoutboxInterval); break; }); }while (url);