jquery getscript <script> tags

Posted by user1871612 on Stack Overflow See other posts from Stack Overflow or by user1871612
Published on 2012-12-03T04:50:47Z Indexed on 2012/12/03 5:03 UTC
Read the original article Hit count: 184

Filed under:

To ask about getscript

html Code as follows:

<!DOCTYPE html PUBLIC "- / / W3C / / DTD XHTML 1.0 Transitional / /
EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html>
    <head> 
        <title>jQuery GetScript</title> 
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> 
        <script type = "text / javascript "> 
            $(document). ready(function () {
                $getScript ('script.js', function (jd) {
                    $.each (test, function (index, value) {
                        console.log (value);
                    });
                });
            }); 
        </script> 
    </head> 
    <body> 
        <div id="dest"> </div> 
    </body> 
</html>

js (1) code are as follows: -

<script type='text/javascript'> var test = []; test [0] = ['111 ', '222']; </ script>

js (2) Code as follows: -

var test = []; test [0] = ['111 ', '222'];

The problem is as follows: - Run js (1) code will appear: - Uncaught SyntaxError: Unexpected token <

No problem running js (2)

Would like to ask how we can run js (1) can not go wrong Thank! Badly written, please forgive me.

© Stack Overflow or respective owner

Related posts about jQuery