jQuery .load动态图片 [英] jquery .load dynamic image

查看:140
本文介绍了jQuery .load动态图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以将.load事件(或任何其他jquery事件)与诸如此类的动态图像一起使用

Is there any way I can use the .load event(or any other jquery event) with a dynamic image such as this

每当我尝试使用.load或.get方法将该页面重新加载到文档中时,它在Firefox中以 出现,在Internet Explorer中以 PNG出现.

Whenever I try to use the .load or .get method to reload that page into the document it just come out as �������� in Firefox and �PNG in internet explorer.

我在这里想念什么?最好的方法是什么?

What am I missing here? What would be the best way to do this?

总体上,我要在此处完成的任务是单击链接时将captcha.php文件重新加载到div中,并在不刷新页面的情况下显示不同的验证码图像.

Overall what I'm trying to accomplish here is to reload the captcha.php file into a div when a link is clicked and have a different captcha image be shown without refreshing the page.

可以在这里找到问题
http://www.seewhosoutthere.com/createAccount

The problem can be found here
http://www.seewhosoutthere.com/createAccount

点击验证码旁边的蓝色小刷新"按钮,将得到我正在谈论的结果.

clicking on the little blue "refresh" button next to the captcha will give the result I'm talking about.

该页面当前使用的代码是

The code currently being used for that page is

$('a#refresh').click(function(){
    $('#captcha').load('captcha.php');
});

推荐答案

而不是 .load() (这不是用于二进制数据的原因...这就是为什么使用编码来获得那些有趣的符号的原因),您只需要创建一个具有正确src<img>元素并将其放在文档中所需的位置,例如:

Instead of .load() (which isn't intended for binary data...which is why you get those fun symbols with the encoding) you just need to create an <img> element with the right src and put it where you want in the document, for example:

$("<img />", { src:"http://www.seewhosoutthere.com/captcha"}).appendTo("#myDiv");

您可以在此处进行测试.

这篇关于jQuery .load动态图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆