javascript - I want to make sure function comes after loading of external HTML -


how make sure alert comes after loading of external html?

function changecontent(){   $('#contentmain').load("contentmain.html", function(){     alert("something"); } )} 

i've been playing around $(document).ready, no luck far.

many thanks!

update:

the result of code depends (on what, don't know): alert comes first, comes second...

your code right.

from jquery documentation:

callback function  if "complete" callback provided, executed after post-processing , html insertion has been performed. callback fired once each element in jquery collection, , set each dom element in turn. 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -