pinterest jQuery的ajax

I have been experimenting with a Pinterest style layout and found this website: http://benholland.me/javascript/how-to-build-a-site-that-works-like-pinterest/ via a previous StackOverflow discussion.

I have no problem getting it to work when the .block classes are created in HTML but I'm trying to now get the blocks to display when the .block classes are created in the success function of the ajax call.

I actually have got something working but really not sure if this is the way to do it.

I fire the ajax call on document.ready and then prepare the blocks (Ben Hollands code) on window.load like so...

$(document).ready(function() {
start();

function start() {
    url="path/to/json/data";
    $.ajax({
        type: "POST",
        url: url,
        dataType: "json",
        cache: false,
        success: function(response){
            var result='';
            $.each(response, function(k, v){                
                result += '<div class="block">' + v.text + '</div>';
            });

            $(".blocks").html(result);
        }
    });
}
});

and then...

$(window).load(function() {
var colCount = 0;
var colWidth = 0;
var margin = 10;
var spaceLeft = 0;
var windowWidth = 0;
var blocks = [];
setupBlocks();

function setupBlocks() {
    windowWidth = $(window).width();
    blocks = [];

    colWidth = $('.block').outerWidth();

    // Calculate the margin so the blocks are evenly spaced within the window
    colCount = Math.floor(windowWidth/(colWidth+margin*2));
    spaceLeft = (windowWidth - ((colWidth*colCount)+(margin*(colCount-1)))) / 2;

    for(var i=0;i<colCount;i++){
        blocks.push(margin);
    }
    positionBlocks();
}

function positionBlocks() {
    $('.block').each(function(i){
        var min = Math.min.apply(Math, blocks);
        var index = $.inArray(min, blocks);
        var leftPos = margin+(index*(colWidth+margin));
        $(this).css({
            'left':(leftPos+spaceLeft)+'px',
            'top':min+'px'
        });
        blocks[index] = min+$(this).outerHeight()+margin;
    }); 
}   
});

what do ya reckon?