I have a simple website that grabs html using ajax and place it in some div (AjaxPlaceHolder).
For example here is my webpage:
<html>
<body>
// some html...
<div id="AjaxPlaceHolder"></div>
</body>
<div id="footer"></div>
</html>
now my problem is that when I get the html using ajax I get something like:
<script type="text/javascript" src="js/someJsFile.js"></script>
<table>html content</table>
// more html
note the line:
<script type="text/javascript" src="js/someJsFile.js"></script>
I don’t want to place the html content until the browser downloads that file (someJsFile.js). How could I be able to tell when the browser downloads that script? I know I can place the someJsFile.js content in there and wrap it around <script type="text/javascript"> tags but it will be nice if I could have the .js files separated.
edit:
Here is what I will like to do in other words:
get html using ajax. don’t render the html (place it meanwhile in a hidden div) utnill the document is done downloading the necessary images and scripts
You can separate the javascript file load, from the rest part of your html ajax load.
If you separate it you can synchronous load the external scripts, and that way you can be sure that they loaded first.
in simple javascript you set the Synchronous flag when you make open.
In jQuery
About Synchronous call : http://www.hunlock.com/blogs/Snippets:_Synchronous_AJAX
jQuery call : http://api.jquery.com/jQuery.ajax/