几秒钟后切换图标模式

时间:2015-11-24 09:30:25

标签: jquery ajax

您有以下ajax功能。点击链接后,图标应该从" off"到"工作"图标,在工作结束时,图标应替换为" on"。

我希望图标会切换回"关闭"几秒钟之后" on"状态。有人可以告诉我该怎么做吗?我是Ajax的新手。

$.ajax({
    url: '/work', type: "GET", 
    beforeSend: function (data, jqXHR) {
        $('#status').attr("src", "/img/_working.gif");
    },
    success: function (data, textStatus, jqXHR) {
        $('#status').attr("src", "/img/_on.png");
        $("#work").html(data)
        $("#work").show()
    },
    error: function (jqXHR, textStatus, errorThrown) {
       $('#status').attr("src", "/img/_error.gif");
        alert('error')
    }
});

<img src="/img/_off.png" class="img-swap" id="status" style="width: 20px;height: 20px;"/>

1 个答案:

答案 0 :(得分:3)

尝试setTimeout:

=========== TXT ============

<?php
/* Multi-line
comment */
$var = 1;


=========== NEW TXT ============

<?php
/* Multi-line
comment */
$var = 1;

其中3000是以毫秒为单位的时间延迟

相关问题