html()
is a synchronous operation. The actual updating of the DOM depends on what your html content is. If you have <img>
or <iframe>
tags, they will take time to load. The next statement following the html()
should immediately see the new html contents.
Did you mean load()
instead?
[Edit] Based on your comment, it is probably your $.ajax
failing. Not html()
. Try attaching a failure handler to ajax call and retry from there? Although, if your server side code silently fails with a 200 code, the failure event doesn't get called. In that case, you can validate the html value before you set it to the element.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…