如何显示在几秒钟后引导收藏夹点击
问题描述:
我的工作中,我要显示每个图像收藏画廊后 - 所以我想在收藏夹如何显示在几秒钟后引导收藏夹点击
有没有办法做到这一点有些延迟?
代码:
$(document).on('click', '.varr', function() {
var post_id = $(this).attr('data-id');
$.ajax({
url: "<?php echo get_template_directory_uri(); ?>/post-result.php",
type: 'POST',
dataType: "html",
data: {
post_id: post_id
},
success: function(response) {
//$('#loaddata').html(response);
$('#loaddata').html(response);
// alert(response)
}
});
setTimeout(function() {
$('.remodal').modal('hide');
}, 3000);
})
答
您可以添加这个脚本:
<script>
$(document).on('click', '.varr', function() {
//Put Loader here
$('#loaddata').html("");
var post_id = $(this).attr('data-id');
$.ajax({
url : "<?php echo get_template_directory_uri(); ?>/post-result.php",
type : 'POST',
dataType: "html",
data : { post_id : post_id },
success : function(response) {
//Remove loader here
$('#loaddata').html(response);
}
});
})
</script>
我希望它会为你工作!
+0
是的...它的好..但需要更多的更正 – varsha
你已经在使用'setTimeout'了 - 你不能再使用它吗?将'$ .ajax'放入setTimeout中,或将$(“#loaddata”)...放在一个中。 –
我只是想settimeout函数,但它不工作 – varsha
请提供小提琴,以更好地理解。 –