日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ajax等待进度数,如果ajax少于X秒,如何延迟显示进度?

發(fā)布時間:2025/3/20 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ajax等待进度数,如果ajax少于X秒,如何延迟显示进度? 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

對于我能夠找到解決方案的好答案。

我最終想要本地化" loading"要基于元素ID顯示的圖像。全局ajaxStart()和ajaxComplete()功能不會處理本地事件。所以我用超時切換到beforeSend()函數(shù):

$('.item').click( function (e) {

e.preventDefault();

var theID = $(this).attr('data');

var theInfo = $('.holder#h' + theID);

var loader = $('.waiting#w' + theID);

$('.holder').slideUp(); //closes any open data holders

var ajaxLoadTimeout;

if (!$(theInfo).hasClass('opened')) {

$(this).addClass('clicked');

$(theInfo).addClass('opened');

$(theInfo).html(''); //removes any existing data

$.ajax({

url: '_core/inc/getdata.php',

type: 'POST',

data: ({dataid: theID}),

dataType: 'html',

//shows LOCAL loader before ajax is sent

//but waits 3 milliseconds before doing so

//most of the ajax calls take less than 3ms

//without the timeOut the loader "flashes" for a milisecond

beforeSend : function() {

ajaxLoadTimeout = setTimeout(function() {

$(loader).show();

}, 300);

},

success: function(data) {

$(theInfo).html(data);

//Hides LOCAL loader upon ajax success

clearTimeout(ajaxLoadTimeout);

$(loader).hide();

},

complete: function(){

$(theinfo).slideDown();

}

});

} else {

$(this).removeClass('clicked');

$(theInfo).removeClass('opened').slideUp();

}

});

相關的PHP / HTML:

echo '

'.$this_title.'

';

CSS:.waiting { discplay: none; }

我不知道這是對還是錯,但似乎在這里按預期工作。

如果該項目的加載時間超過幾毫秒,它允許字體真棒圖標出現(xiàn)在項目標題旁邊。

總結

以上是生活随笔為你收集整理的ajax等待进度数,如果ajax少于X秒,如何延迟显示进度?的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內容還不錯,歡迎將生活随笔推薦給好友。