【发布时间】:2014-07-26 06:08:09
【问题描述】:
我试图从 magnific popup 的文档中实现如何从 ajax 调用 (http://dimsemenov.com/plugins/magnific-popup/documentation.html#ajax_type) 中仅检索特定的 div,但我的预期响应没有奏效。我发现,文档中有一个拼写错误: ParseAjax 和 AjaxContentAdded 都是用小写字母写的。在代码中,它是用大写驼峰写的。但这并没有解决我的问题。
$('.JS_ajaxpopup').magnificPopup({
type: 'ajax',
ajax: {
cursor: 'mfp-ajax-cur'
tError: '<a href="%url%">The content</a> could not be loaded.'
},
callbacks: {
ParseAjax: function(mfpResponse) {
console.log('test');
mfpResponse.data = $(mfpResponse.data).find('#mainContent');
console.log('Ajax content loaded:', mfpResponse.data);
},
AjaxContentAdded: function() {
// Ajax content is loaded and appended to DOM
console.log(this.content);
}
}
});
甚至我的测试也没有出现在我的控制台中。也许有人暗示我为什么没有得到回应。弹出窗口已正确打开,但没有解析任何内容。我也试过这个:
ParseAjax: function (mfpResponse) {
mfpResponse.data = "<div class='wrapping'>" + mfpResponse.data + "</div>";
},
AjaxContentAdded: function () {
this.content;
}
不幸的是,什么也没发生。
【问题讨论】:
-
您是否在
<a href="path-to-file.html" class="ajax-popup-link">Show inline popup</a>中设置了有效路径
标签: jquery ajax magnific-popup