【发布时间】:2013-12-01 14:41:24
【问题描述】:
我对这个函数有一个大问题:
(function($) {
$.fn.scrollPagination = function(options) {
function getData() {
$.post('load.php', {
action: 'scrollpagination',
number: $settings.nop,
offset: offset,
}, function(data) {
// Change loading bar content (it may have been altered)
$this.find('.loading-bar').html($initmessage);
// If there is no data returned, there are no more posts to be shown. Show error
if (data == "") {
$this.find('.loading-bar').html('<span class="label label-info">No News</span>');
}
else {
// Offset increases
offset = offset + $settings.nop;
// Append the data to the content div
$this.find('.content').append(data);
// No longer busy!
busy = false;
}
});
}
getData(); // Run function initially
});
}
})(jQuery);
(来自:http://www.inserthtml.com/2013/01/scroll-pagination/)
我将在另一个 HTML 文件中调用函数“getData”。
$(document).ready(function() {
$('#statustext').submit(function() {
....
})
.done(function(data) {
getData();
})
.fail(function() {
...
});
return false;
});
});
但是,这行不通。大家可以帮帮我吗? 我在 Stackoverflow 和 Google 中搜索过,但一无所获。
【问题讨论】:
-
试试 .scrollPagination.getData()
-
不起作用。 .scrollPagination.getData() 或 scrollPagination.getData()
-
不在作用域内,所以无法从插件外部访问