jQuery - script tags in the HTML are parsed out by jQuery and not executed
Posted
by Jose Jose
on Stack Overflow
See other posts from Stack Overflow
or by Jose Jose
Published on 2010-04-23T14:26:12Z
Indexed on
2010/04/23
15:13 UTC
Read the original article
Hit count: 426
JavaScript
|jQuery
I have an HTML page like so:
<html>
<body>
<div id='something'>
...
<script>
var x = 'hello world';
</script>
...
</div>
</body>
</html>
On another page, I am doing this:
$.ajax({
url: 'example.html',
type: 'GET',
success: function(data) {
$('#mydiv').html($(data).find('#something').html());
alert(x);
}
});
jQuery, however, is not executing the javascript in the first file, even though the documentation says it does. How can I make it do that?
EDIT: Unfortunately in the real world application I am working on I don't have control over what the "included" page has. We are on the same domain, but I can't modify the code that it outputs as it is a packaged product our IT department will not let us modify.
© Stack Overflow or respective owner