gpt4 book ai didi

php - 在引导模式框中加载远程数据之前添加等待消息

转载 作者:搜寻专家 更新时间:2023-10-31 21:04:59 26 4
gpt4 key购买 nike

我有这段代码可以将远程 php 数据加载到引导模式框中:

$(function() {
$(window).bind("resize", function() {
if ($(this).width() < 400) {
$('#tabs-content').removeClass('col-xs-10').addClass('col-xs-12')
} else {
$('#tabs-content').removeClass('col-xs-12').addClass('col-xs-10')
}
}).resize();
});
$(function() {
$(document).on('click', '.push', function(e) {
e.preventDefault();
var id = $(this).attr('id');
$.ajax({
type: 'post',
url: 'details.php', // in here you should put your query
data: {
'bookid': id,
'lang': 'fa',
'csrf_token': 'MTQ0OTQxNDQ0MUVvN2JwNXNJRHVxMDZmOXFpQm1ROFNNTk1UZ3lPMGZO'
},
success: function(r) {
// now you can show output in your modal
$('#bookdetails').modal({
backdrop: 'static',
keyboard: false
}) // put your modal id
$('.something').show().html(r);
}
});
});
});

这对我有用,但我需要在加载数据之前显示加载 message/image

如何添加等待消息/图标?!

最佳答案

您只需要在 Ajax 调用 之前显示 image/message 并将其隐藏在 success: function(r)

假设您有图像要在模态加载之前显示,例如 HTML 图像

<img class="progress" src="http://downgraf.com/wp-content/uploads/2014/09/01-progress.gif" style="display:none;">

在 JS 中,仅使用 .show() 函数显示图像,并且在 success: function(r) 模式加载后使用 .hide( ) 函数

$(document).on('click', '.push', function(e) {
e.preventDefault();
var id = $(this).attr('id');
$(".progress").show(); // <-- Show progress image
$.ajax({
type: 'post',
url: 'details.php', // in here you should put your query
data: {
'bookid': id,
'lang': 'fa',
'csrf_token': 'MTQ0OTQxNDQ0MUVvN2JwNXNJRHVxMDZmOXFpQm1ROFNNTk1UZ3lPMGZO'
},
success: function(r) {
// now you can show output in your modal
$('#bookdetails').modal({
backdrop: 'static',
keyboard: false
}) // put your modal id
$('.something').show().html(r);
$(".progress").hide(); // <-- Hide progress image
}
});
});

Minimal example with delay and fade

关于php - 在引导模式框中加载远程数据之前添加等待消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34119171/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com