【发布时间】:2017-04-26 15:17:41
【问题描述】:
我如何在单击类按钮后:load-more-reviews,添加 3 秒延迟写入“正在加载...”然后显示数据?
这是我的 Ajax:
// Loading button
$('button.load-more-reviews').on('click', function(e) {
e.preventDefault();
var _this = $(this);
var product_id = _this.data('product-id');
var limit = _this.data('limit');
var _btn_text = _this.html();
_this.html('Loading...');
_this.attr('disabled', true);
$.ajax({
type: 'POST',
url: 'actions/ajax.php',
data: {
action: 'fetch_reviews',
product_id: product_id,
limitcount: limit
},
dataType: 'json',
success: function(r) {
_this.html(_btn_text);
_this.attr('disabled', false);
console.log(r);
_this.data('limit', r['limit']);
if (r['status'] == '1') {
$('div.reviews-block').append(r['html']);
} else if (r['status'] == '2') {
_this.hide();
}
return false
}
});
});
【问题讨论】:
-
你在找setTimeout
标签: jquery ajax settimeout