<span style="font-style: normal;"><strong>$.ajax({ url : options.asynOptions.url,type : 'post',dataType : 'json',data : getAjaxData(options.asynOptions.form),success : function(data){ var html = '',allow = options.asynOptions.return,itemClass = options.itemClass,imageClass = options.imageClass,count = 0; for(var pro in data){ html += '<div class="'+itemClass+'">'; html += '<img class="'+imageClass+'" src="'+data[pro][allow[0]]+'" />'; html += '<span>'+data[pro][allow[1]]+'</span>'; html += '<span>'+data[pro][allow[2]]+'</span>'; html += '</div>'; count++; } $this.append(html); var $colsHeight = []; $("."+imageClass).load(function(){ count--; if(count == 0){ var itemWidth = getFullWith($("."+options.itemClass).eq(0)),cols = getColNumber($this,itemWidth); $("."+imageClass).each(function(i,img) { var iheight = getItemFullHeight($("." + itemClass).eq(i)); if (i < cols) { $colsHeight[i] = iheight; } else { var minH = Math.min.apply(null,$colsHeight); var minHIndex = $.inArray(minH,$colsHeight); $("." + itemClass).eq(i).css({ 'position': 'absolute','top': minH,'left': $(".waterfall_item").eq(minHIndex).position().left }); $colsHeight[minHIndex] += iheight; } }); } }); } });</strong></span>