I have placed the below code inside of the tag.
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('head').append('<script type="text/javascript" src="../wp-includes/js/thickbox.js"></script>');
});
</script>
I got an error of "unterminated string literal".
I have placed the below code inside of the tag.
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('head').append('<script type="text/javascript" src="../wp-includes/js/thickbox.js"></script>');
});
</script>
I got an error of "unterminated string literal".
Share Improve this question edited Jan 30, 2014 at 4:28 Balaji Kandasamy 4,50610 gold badges41 silver badges58 bronze badges asked Dec 11, 2010 at 16:47 A.C.BalajiA.C.Balaji 1,1135 gold badges13 silver badges23 bronze badges 04 Answers
Reset to default 10The problem is ing from the fact that your code includes </script>
in it. This is causing the browser to think that you're terminating your <script>
tag early. If you change your code to the following, it will work:
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('head').append('<script type="text/javascript" src="../wp-includes/js/thickbox.js"></' + 'script>');
});
</script>
As you can see, the above code breaks the </script>
in your string into '</' + 'script>'
, so that the browser doesn't parse it as a closing tag.
The code you posted doesn't have an unterminated string literal. The error means that you've started a string with a single or double quote, but don't have a second quote of the same kind to close the string.
"unterminated string literal error" is not a Javascript error.
It hints towards a PHP script error, though. Post that code and you shall receive help.
Balaji ,
Use jquery' getscript , its very nice way of doing it , it will append in head section and less changes of errors
http://api.jquery./jQuery.getScript/