How can I automate chaining a series of ajax requests?
<p>Look at the lower part of my function: I want to repeat  <code>info(url_part1 + next + url_part2, function(next) {</code> couple of times. Is there a smarter way than one presented below (maybe some kind of loop)? I've been thinking whole day and I can't devise anything.</p>

<pre><code> function info(link, callback) {
        $.getJSON(link, function(json) {
            $.each(json.data.children, function(i, things) {
                $("#threadlist").append('&lt;img src="' + things.data.url + '"&gt;');
            });
            callback(json.data.after);
        });
    }
    var url_first = "http://www.reddit.com/r/aww/.json?jsonp=?";
    var url_part1 = "http://www.reddit.com/r/aww/.json?after=";
    var url_part2 = "&amp;jsonp=?";

    info(url_first, function(next) {
        info(url_part1 + next + url_part2, function(next) {
            info(url_part1 + next + url_part2, function(next) {
                info(url_part1 + next + url_part2, function(next) {
                    info(url_part1 + next + url_part2, function(next) {

                    });
                });
            });
        });
    });
</code></pre>

<p>Js fiddle: <a href="http://jsfiddle.net/rdUBD/1/" rel="nofollow">http://jsfiddle.net/rdUBD/1/</a></p>
