My page has a tag:
<script id='header' src='/Templates/Shared/Header.tmpl.html' type='text/html'></script>
Firebug tells me that Firefox 5 is requesting this resource. On the HTML tab, I can navigate to the script element and see that it contains the contents of /Template/Shared/Header.tmpl.html.
jQuery, however, insists that the script tag is empty. $('#header').html() returns an empty string. I don't understand why.
Yes, I can load the file with $.get() and use $('#header').html(data) to set the contents. Then I can use it as I would expect. This obviously generates a second request, which I would like to avoid.
I know this is old, but the answer is simple. The script tag simply does not contain any text or html.
<script id='...' src='...' type='...'></script>
There are no elements or text within the tag. The script will be requested and loaded into memory (if the script type has a handler), but the actual text itself will not be inserted into the DOM.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With