【发布时间】:2014-11-15 11:53:26
【问题描述】:
我有一个字段和一个图像容器。
在这个容器中有一个默认图像。
我希望用户放置图片的链接然后提交,然后将图片添加到 默认图片的src属性。
我的问题,我应该如何加载图像,在此期间向用户显示一个进度条,加载完成后,隐藏 URL。我现在主要关心的是如何加载资源。
现在我已经编写了这个脚本:
jQuery("#logo-file-upload").on("click", function(){
// when user clicks the submit button
$("#url-logo-progress").show(); // show the progress bar to it
var logoUrl = $("#logo-url").val(); // pick up the inserted URL
$("#image-width").attr("src", logoUrl); // and put the URL into the src attribute of the image
});
虽然我需要这样的东西:
$.imageLoad({ url : "url/to/image.jpg",
complete : function(){
alert("upload finished!");
});
我写回调和状态没有问题,但我不知道如何加载资源。
提前致谢
【问题讨论】:
-
看到这个article
-
见github.com/glenswift/imageloader。也许对你有帮助
标签: javascript jquery html image