weixin_33724570 2015-08-20 13:28 采纳率: 0%
浏览 19

单击JS加载图像

I need to load an image, js need to get link url and print this image on screen. But it is not working.

What is wrong with my script? what can I do to make it work and improve it?

html

<div id=img></div>

<div id=loading></div>


<a href=http://png-5.findicons.com/files/icons/1580/devine_icons_part_2/128/my_computer.png class=postmini>Open image 1</a>
<br>
<a href=http://www.iconshock.com/img_jpg/BETA/communications/jpg/256/smile_icon.jpg class=postmini>Open image 2</a>

js

$(function() {
$(".postmini").click(function(){

var element = $(this);
var I = element.attr("href");

$("#loading").html('<img src="loader.gif" align="absmiddle">&nbsp;loading...');

$("#loading").ajaxComplete(function(){}).slideUp();
$("#img").append(I);

 });
});

https://jsfiddle.net/u6j2udzb/

and this loading div, what I need to do to make it work properly?

  • 写回答

5条回答 默认 最新

  • weixin_33737134 2015-08-20 13:34
    关注

    You are not running an ajax script. ajaxComplete is only fired after an ajax script completed.

    Whenever an Ajax request completes, jQuery triggers the ajaxComplete event. Any and all handlers that have been registered with the .ajaxComplete() method are executed at this time.

    You should ad an ajax script and than ajaxComplete will run if you registered the ajaxComplete method.

    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料