Javascript 如何在jquery中对beforeSend()上的加载程序进行延迟
我使用jQueryAjax发布表单数据。加载正在运行beforeSend()函数,但我想让它延迟几秒钟并提交数据Javascript 如何在jquery中对beforeSend()上的加载程序进行延迟,javascript,jquery,html,ajax,Javascript,Jquery,Html,Ajax,我使用jQueryAjax发布表单数据。加载正在运行beforeSend()函数,但我想让它延迟几秒钟并提交数据 $.ajax({ type : 'POST', url : 'ajax_process_register.php', data : data, beforeSend: function() { //show
$.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
<代码>设置超时(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);
怎么做,兄弟?我是jquery新手,你能帮我举个例子吗?为ya=D编辑了一个例子