我有一个jquery ajax请求。 在页面加载显示加载图像。 这种运作良好,但我想显示加载GIF最少1秒。
i have a jquery ajax request. On page load a loading-image is displayed. this is working well, but i want to display the loading gif for a minimum of 1 second.
我已经尝试过这样的:Ajax装载机图片:?如何设置,在此期间装载器显示一个最短持续时间, 但它不工作。
I've already tried this: Ajax loader image: How to set a minimum duration during which the loader is shown? , but it's not working.
我的code是:
<div id="ajaxcontent"><img src="loader.gif" id="ajaxloading" /></div>
和
$.ajax({
// some code for the request
success: function () {
$('#ajaxcontent').text(myResultText);
}
我也试图添加.delay(1000)的文字显示过,但是这也不能正常工作。
I've also tried to add .delay(1000) before the text is shown, but this also does not work.
你试试这个?
setTimeout(function() { $('#ajaxcontent').text(myResultText);},
1000);