3

我的目标是在我进行 AJAX 调用时显示一个加载弹出窗口(其中包含一个 GIF)。我正在使用jQuery UI 模态对话框,我在其中使用 CSS 插入 GIF 动画。在 AJAX 调用开始之前,我打开对话框并在调用结束后立即关闭它。问题是当 AJAX 调用运行时 GIF 停止工作,并且在所有浏览器中都发生了这种情况。我正在使用以下代码:

<div id="loadingScreen" title="Loading">Please wait...</div>

#loadingScreen {
    background: url(http://regretless.com/stuff/jQuery/images/loading.gif) no-repeat 5px 8px;
    padding-left: 25px;
}

$("#loadingScreen").dialog('open');
setTimeout(function () {
  $.ajax({
    type: "GET",
    url: "testing.txt",
    async: true,
    dataType: "text",
    success: function (returnText) {
      $("#viewDescription").text(returnText);
      $("#viewGroupID").text(" " + t.id);
      $("#loadingScreen").dialog('close');
      $('#View').dialog('open');
    },
    error: function (xhr, status, error) {
      $("#loadingScreen").dialog('close');
      alert("An error has occured");
    }
  });
}, 10);

谁能告诉我可能是什么问题?

4

1 回答 1

0

因为这是背景,您需要将焦点设置为#loadingScreen 以保持动画继续播放。

于 2012-07-12T14:00:45.000 回答