你能帮我添加一个“throbber”吗?到这个ajax函数
基本上,在我的页面上,当函数执行时,图像会被调用到 div#imagebox
。但有时图像很大,可能需要一段时间才能加载,尤其是在尚未加载到缓存中的情况下。我想通知用户请求正在处理。我想我可以用一个 throbber 来做到这一点。我希望在图像准备好之前将 throbber 显示在 div#imagebox
中。然后我希望那种悸动消失。
我看过这个页面 http://plugins.jquery.com/project/throbber 但是我真的不明白我应该做什么。
我可以在现有函数中添加类似 $("div#imagebox").throbberShow(true);
的内容吗(见下文?)但是我应该在哪里添加它呢?我需要参数 true
吗?
感谢您的帮助。
function showImage(ms, pid)
{
$.get("../msimages/image.php", {ms: ms, pid: pid}, function(txt)
{
$("div#imagebox").html(txt);
});
}
Basically, on my page an image is called to div#imagebox
when the function is executed. But sometimes the image is large and can take awhile to load, especially if it hasn't been loaded into the cache yet. I would like to give the user some notice that the request is being processed. I think I can do this with a throbber. I would like the throbber to be displayed in div#imagebox
until the image is ready. Then I would like the throbbber to disappear.
I've looked at this page http://plugins.jquery.com/project/throbber but I don't really understand what I'm supposed to do.
Could i add something like $("div#imagebox").throbberShow(true);
into the existing function (see below?) But where would I add it? Do i need the parameter true
?
Thanks for your help.
function showImage(ms, pid)
{
$.get("../msimages/image.php", {ms: ms, pid: pid}, function(txt)
{
$("div#imagebox").html(txt);
});
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您的情况下,您应该按如下方式添加它。我不认为 true 参数是必要的:
这个应该将图像加载到#imagebox中,当ajax加载完成时,它应该覆盖其中的任何内容。
In your case it looks like you would add it as follows. I don't believe the true parameter is necessary:
This should load the image into #imagebox, and when the ajax is done loading, it should overwrite whatever is in there.