等待.load完成,然后执行某些操作 [英] Wait for .load to finish and then do something

查看:89
本文介绍了等待.load完成,然后执行某些操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过.load('url')加载外部脚本,需要等待它完成,以便我可以更新图像的来源.有时加载速度足够快,因此可以应用图像重新加载,但是大多数情况下,加载时间太长,并且首先发生图像重新加载,因此图像实际上并没有改变.

I'm loading an external script through .load('url') and need to wait for it to finish so I can update the source of an image. Sometimes load is fast enough that the image reload applies, but most of the time it takes too long and the image reload happens first, so the image doesn't actually change.

推荐答案

load方法具有在请求完成时执行的回调函数.我认为您应该使用它.

load method has callback function that is executed when the request completes. I think you should use it.

这篇关于等待.load完成,然后执行某些操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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