i’m loading, using the JQuery ajax() method, an external page with both html and javascript code:
<script type="text/javascript" src="myfile.js"></script>
<p>This is some HTML</p>
<script type="text/javascript">
alert("This is inline JS");
</script>
and setting the results into a div element, using the html() method.
While the html() method properly evaluates the inline JS code, it doesn’t download and evaluate the external JS file “myfile.js”.
Any tip for this issue?
If you control the external page you could change this
to
Demo: http://jsbin.com/ucomu3/3 loads http://jsbin.com/otopi/3 via
$.ajaxand sets the returned data viahtml()http://jsbin.com/otopi/3 contains an inline script tag and one with a full qualified URL in the src-attribute which points to http://jsbin.com/uyova3So if you open http://jsbin.com/ucomu3/3 you see “This is some HTML” and two alerts which say “I’m the external local js” and “This is inline JS”