动态图像刷新 [英] Dynamic image refresh
问题描述
我将如何更新每两秒钟在服务器上更新一次的映像,而无需用户按下刷新按钮,我的第一个猜测是ajax,但我之前从未真正使用过.有人可以指出我正确的方向吗?
How would I go about updating an image that gets updated on a server every couple of seconds with out the user having to hit the refresh button, my first guess was ajax but I haven't really worked with it before. Could someone point me in the right direction?
忘记提及图像是由perl脚本生成的.gif-尝试从url抓取图像会返回脚本本身.
Forgot to mention that the image is a .gif generated by a perl script - trying to grab it from url returns the script itself.
推荐答案
您的Perl脚本似乎有问题.尝试通过URL访问图像应该仍然返回图像.它应该返回二进制数据,而不是脚本.您还应该将响应的Content-type标头设置为image/gif.在尝试修复JavaScript代码之前,请验证它是否确实返回了二进制数据.
It seems there is something wrong with your Perl script. Trying to access the image by the URL should return an image anyway. It should return binary data and not a script. You should also set the Content-type header of the response to image/gif. Verify if it indeed returns binary data before trying to fix your JavaScript code.
这篇关于动态图像刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!