jQuery的AJAX加载 - 显示一个最小的加载图像。 1秒 [英] jQuery ajax loading - display the loading image for a min. of 1 second

查看:111
本文介绍了jQuery的AJAX加载 - 显示一个最小的加载图像。 1秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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.

我已经尝试过这样的:<一href="http://stackoverflow.com/questions/5025839/ajax-loader-image-how-to-set-a-minimum-duration-during-which-the-loader-is-show">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);

这篇关于jQuery的AJAX加载 - 显示一个最小的加载图像。 1秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆