通知超时功能

时间:2014-05-13 11:09:18

标签: javascript jquery fadein fadeout

我有一个按钮,可以根据某些参数获取图像,如果成功或失败,它会输出带有flash消息的范围。

      $.getJSON('<%= EVERCAM_API %>cameras/test.json?' + params.join('&'))
      .done(function (resp) {
        console.log('success');
        $('#test-error').text('Snapshot successfully retrieved');
        $('#testimg-add').attr('src', resp.data);
      })
      .fail(function (resp) {
        $('#test-error').text(resp.responseJSON.message);
        console.log('error');
      })
      .always(function () {
        l.stop();
        clearInterval(interval);
      });
});

我想要的是按下按钮时页面上显示的#text错误

 <span id="test-error"><%= flash[:message] %></span>

沿着这些线淡入和淡出

that.show = function(text) {
  clearTimeout(hideHandler);

  elem.find("span").html(text);
  elem.delay(200).fadeIn().delay(4000).fadeOut();
};

以上fadeIn fadeOut我从其他地方获得的代码片段,我不太确定如何将其写入我现有的函数以使#test-error渐入淡出。目前它只是输出年龄并停留。

有没有人对我将如何解决这个问题有任何建议?

0 个答案:

没有答案