[英]How do I do this in JQuery? (get the HTML returned from AJAX-GET and turn it into an object)
$.ajax({
method:"get",
url:"/wall",
data:"ajax=1",
beforeSend:function(){},
success:function(html){
$("#grid_mason").append(html); //Add the next boxes to the Grid.
$(this).masonry({ appendedContent: $( html ), animate:false, resizeable:false });
});
}
});
http://desandro.com/demo/masonry/docs/appending.html
我正在使用該Masonry插件,並且有關附加的討論。
我認為您需要將代碼重構為:
var thiz = this;
$.ajax({
method:"get",
url:"/wall",
data:"ajax=1",
beforeSend:function(){},
success:function(html){
$("#grid_mason").append(html); //Add the next boxes to the Grid.
$(thiz).masonry({
appendedContent: $( html ),
animate:false,
resizeable:false});
});
}
});
如果您將砌體應用於#grid_mason
嘗試從以下位置更改代碼
$("#grid_mason").append(html);
$(thiz).masonry({ appendedContent: $( html ), animate:false, resizeable:false });
對此
$("#grid_mason").append(html)
.masonry({ appendedContent: $( html ), animate:false, resizeable:false });
不知道我是否可以建議其他任何內容而無需查看更多代碼。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.