[英]How to fix beforesend ajax small loader inside individual row in table
[英]How to make delay for loader on beforeSend() in jquery
我正在使用 jquery ajax 發布表單數據。 加載正在運行 beforeSend() function 但我想讓它延遲幾秒鍾並提交數據
$.ajax({
type : 'POST',
url : 'ajax_process_register.php',
data : data,
beforeSend: function()
{
//show loader untill getting the response from the ajax.
$('.loader').show();
setTimeout(function () {
$('.loader').hide();
th.submit();
}, 3000);
},
// after getting success response.
success : function(data)
{
裝載機並沒有耽誤我的時間。 它立即被解雇成功
在 ajax 帖子上執行setTimeout
。 setTimeout(ajaxFn, msDelay)
。
例子:
function ajaxFn() {
$.ajax({
type: 'POST',
url: 'ajax_process_register.php',
data: data,
beforeSend: function () {
$('.loader').show();
setTimeout(function () {
$('.loader').hide();
th.submit();
}, 3000);
},
success: function (data) {
}
});
}
// One ms second is 1000
const delayInMs = 3000;
setTimeout(ajaxFn, delayInMs);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.