#2 will probably be your best bet. I am pretty sure that if the page you're retrieving has <script> blocks, they'll be parsed out and inserted into the <head> of the document -- before the actual HTML is injected into the <body>.
On Apr 23, 9:30 am, Brandon <brandon.goo...@gmail.com> wrote: > Greetings All, > > I am loading content into a page using the following: > > $("#someDiv).load("/Some.action",{id: someId}); > > The document that results from Some.action contains javascript at the > top. I want the javascript to be executed when the resulting content > is fully ready/loaded. > > I attempted to use the document ready: > > <script type="text/javascript"> > $(function() { > console.log("READY"); > }); > </script> > > However the document is already ready since I am loading it into an > existing page. I see READY in the console before the content is > finished rendering. > > The only solutions I could come up with were: > 1) Place the javascript at the bottom of the loaded page so that the > prior DOM will have been loaded. > 2) Place javascript into the callback function of the $ > ("#someDiv).load(...) call. > > Number 1 is fine. I'm just wondering if this is an acceptable way or > if there is a better way. > Number 2 is not acceptable because the fragment may be called from > several other locations and I don't want repetitious code. > > Am I being thick headed here? Is there another better way? > > Brandon