【发布时间】:2011-07-19 16:48:59
【问题描述】:
使用下面的代码,我可以在加载 AJAX 数据时正确显示对话框,但动画 GIF 不是动画 - 看起来真的很糟糕。
CSS:
.loading {
background: url('/images/loading.gif');
}
JavaScript:
$(function() {
$("#createButton").click(function(e){
e.preventDefault();
var $form = $(this).closest("form");
$("#pleaseWait-dialog").dialog({
modal: true,
height: 200,
resizable: false,
draggable: false
});
$.ajax({
type: "GET",
url: "myScript.cfm",
async: true,
success: function() {
$form.submit();
}
});
return false;
});
});
HTML:
<form action="post.cfm" method="post">
<input
id="createButton"
type="submit"
name="createButton"
value="Create a New Thing" />
</form>
<div id="pleaseWait-dialog" title="Gathering Data" style="display:none;">
<span class="loading"></span>
<p>Thank you for your patience while we gather your data!</p>
</div>
【问题讨论】:
-
你的 gif 动画在哪里?我在任何地方都看不到对 gif 的引用...如果您通过样式添加它,我不确定作为背景图像的 gif 是否会动画...
-
GIF 是在 CSS 中的(我添加它是为了澄清)。仅供参考,作为背景图像的 GIF 确实具有动画效果。
标签: jquery jquery-ui jquery-ui-dialog