javascript - Jquery Show image for some time - Stack Overflow

On changing the select option i am displaying the image and on success of ajax call hiding that image .

On changing the select option i am displaying the image and on success of ajax call hiding that image .. but this happens very fast .. i want to display the image for some time say 2 seconds. how to do it

my code

 var div_id = $(this).closest('tr').find('.display_image').attr("id");
 $("#"+div_id).empty().html('<img src="${resource(dir:'images',file:'spinner.gif')}"/>');
 $("#"+div_id).show();

  $.ajax({
                type: "POST",
                url:"${createLink(controller:'s2PublicLifecycle',action:'UpdateField')}",
                data: dataString,
                success: function() {
                  $("#"+div_id).hide();
                }
              }); 

On changing the select option i am displaying the image and on success of ajax call hiding that image .. but this happens very fast .. i want to display the image for some time say 2 seconds. how to do it

my code

 var div_id = $(this).closest('tr').find('.display_image').attr("id");
 $("#"+div_id).empty().html('<img src="${resource(dir:'images',file:'spinner.gif')}"/>');
 $("#"+div_id).show();

  $.ajax({
                type: "POST",
                url:"${createLink(controller:'s2PublicLifecycle',action:'UpdateField')}",
                data: dataString,
                success: function() {
                  $("#"+div_id).hide();
                }
              }); 
Share Improve this question asked Jul 25, 2012 at 9:52 maazmaaz 3,66422 gold badges65 silver badges106 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

use jquery delay:

$("#"+div_id).delay(2000).hide(1);

Here's a jsfiddle

try setTimeout(function() { $("#"+div_id).hide(); }, 2000 );

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744985444a4604583.html

相关推荐

  • javascript - Jquery Show image for some time - Stack Overflow

    On changing the select option i am displaying the image and on success of ajax call hiding that image .

    20小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信