gpt4 book ai didi

javascript - Jquery在php处理时显示消息

转载 作者:行者123 更新时间:2023-12-03 11:37:53 25 4
gpt4 key购买 nike

我正在使用 jQuery ajax 调用来后期处理表单。
我想在处理表单时以及完成操作以显示完整消息时显示加载消息或图像。
我该怎么做?
这是我的 jQuery 代码。

$s('body').on('click', '#group-update', function() {
var formInputs = $s('input').serializeArray();
var groupId = $s(this).data('group');
var error = $s('#modal .info');
var tr = $s('#dataT-attrgroup').find('tr.on_update');

formInputs.push({
name: 'id',
value: groupId
});

$s.ajax({
type: 'post',
url: 'index.php?controller=attribute&method=updateGroup',
data: formInputs,
dataType: 'JSON',
success: function(data) {
if(data.response === false){
error.addClass('info-error');
error.html(data.message);
}else{
oTable.row(tr).data(data).draw();
$s('#modal').modal('hide');
tr.removeClass('on_update');
$s.growl.notice({
title: 'Success',
message: 'Grupul de atribute a fost actualizat'
});
}

}
});
});

最佳答案

在 ajax 函数显示您的加载程序之前,在 ajax 的成功函数中隐藏它。

正如您在我的示例中看到的,我插入了 $('.loader').show();$('.loader').hide();

$('.loader').show();
$s.ajax({
type: 'post',
url: 'index.php?controller=attribute&method=updateGroup',
data: formInputs,
dataType: 'JSON',
success: function(data) {
if(data.response === false){
error.addClass('info-error');
error.html(data.message);
}else{
oTable.row(tr).data(data).draw();
$s('#modal').modal('hide');
tr.removeClass('on_update');
$s.growl.notice({
title: 'Success',
message: 'Grupul de atribute a fost actualizat'
});
}
$('.loader').hide();
}
});

关于javascript - Jquery在php处理时显示消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26406112/

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