我正在使用jQuery ajax調用後處理表單。
我想要在處理表單和完成操作以顯示完整的消息時顯示加載消息或圖像。
我該怎麼做?
這是我的jQuery代碼。jquery顯示消息,而php處理
$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'
});
}
}
});
});
我的驗證之前處理 – speedy 2014-10-16 13:58:55
而PHP調用時 – speedy 2014-10-16 14:01:49
我相信通過Ajax也有一些這方面的先進技術,如文件上傳應顯示加載消息,但如果你想爲了保持簡單,那麼我建議兩個選項: 1.在js中進行檢查, 2.創建2個Ajax請求 – 2014-10-16 14:08:38