unterminated string literal error

前端 未结 4 1379
死守一世寂寞
死守一世寂寞 2020-12-06 15:34

I have placed the below code inside of the tag.



        
相关标签:
4条回答
  • 2020-12-06 15:46

    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.

    0 讨论(0)
  • 2020-12-06 15:49

    The problem is coming 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.

    0 讨论(0)
  • 2020-12-06 15:51

    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.com/jQuery.getScript/
    
    0 讨论(0)
  • 2020-12-06 16:08

    "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.

    0 讨论(0)
提交回复
热议问题