Php 如何在单击几秒钟后显示引导灯箱
我正在一个画廊里工作,在那里我必须在每张图片上显示灯箱——所以我希望灯箱有一些延迟 有办法吗 代码:Php 如何在单击几秒钟后显示引导灯箱,php,jquery,Php,Jquery,我正在一个画廊里工作,在那里我必须在每张图片上显示灯箱——所以我希望灯箱有一些延迟 有办法吗 代码: $(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', d
$(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);
})
$(document).on('click','.varr',function(){
var post_id=$(this.attr('data-id');
$.ajax({
url:“/post result.php”,
键入:“POST”,
数据类型:“html”,
数据:{
post\u id:post\u id
},
成功:功能(响应){
//$('#loaddata').html(响应);
$('#loaddata').html(响应);
//警报(响应)
}
});
setTimeout(函数(){
$('.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>
$(文档).on('click','.varr',function()){
//把加载器放在这里
$('#loaddata').html(“”);
var post_id=$(this.attr('data-id');
$.ajax({
url:“/post result.php”,
键入:“POST”,
数据类型:“html”,
数据:{post_id:post_id},
成功:功能(响应){
//从这里卸下装载机
$('#loaddata').html(响应);
}
});
})
我希望它对你有用 您已经在使用
setTimeout
-不能再使用它吗?要么将$.ajax
放在setTimeout中,要么将$(“#loaddata”)…
放在一个setTimeout中。我只是在尝试setTimeout函数,但它不起作用。请提供fiddle以便更好地理解。提供静态html
和jquery
代码。所以,我们解决!在重读时:您希望延迟到哪里?单击时,在显示项目之前延迟(正如我第一次阅读它),还是延迟然后关闭灯箱?