I have 2 files, the first file has some HTML and a portion of JS. The second file is the main file, and it loads the first file thru' XmlHttpRequest.
The first file is like this:
<div>
My HTML contents
</div>
<script id="my_js_block">
function my_function() {
alert(9);
}
</script>
The second file is like this:
<div id="div_ajax_content">
</div>
<script>
function load_ajax_content() {
//synchronously with XmlHttpRequest(...,...,false);
//...load and throw the first file into 'div_ajax_content'
}
load_ajax_content();
my_function(); <-- fails here
</script>
How to solve this matter?
my_function()