我想將ajax響應加載到colorbox中。 colorbox應該在點擊時打開並顯示加載圖像,直到獲取並顯示內容。將ajax內容加載到colorbox中
我的代碼:
jQuery(".likeBar").colorbox({initialWidth:'460px', initialHeight:'355px', width:'460px', height:'355px', overlayClose:true, html: function() {
var eventID = jQuery(this).data("id");
var sp_response = "";
var the_data =
{
action: 'get_likes',
eventID: eventID,
};
jQuery.post(ajaxurl, the_data, function(sp_response) {
return sp_response;
});
}
});
我的問題: 將抓取的內容將不會被顯示在我的顏色框。 AJAX調用成功,內容被提取,但不顯示。
我的問題: 如何將內容從ajax調用插入到colorbox?
我想要的顏色框下點擊後立即打開而不是在ajax調用完成後。 – Chris 2013-02-15 12:39:05
然後嘗試第二種方法,並用我的答案中的替換Jquery.post簡寫函數。它會加載內容,因爲它會同步! – Ateszki 2013-02-15 12:41:50
但是這會導致瀏覽器停滯,用戶無法做其他任何事情。 – Chris 2013-02-15 12:44:44