Uncaught SyntaxError: Unexpected token <
a.config.js
var a = 3;
index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title></title>
<script type="text/javascript" src="a.config.js"></script>
</head>
<body>
开发者_运维技巧</body>
</html>
If I put this in my web root, chrome gives me the error:
Uncaught SyntaxError: Unexpected token < (a.config.js:1)
Firefox gives me the error
syntax error (a.config.js:1)
If I run it from my filesystem instead of localhost, I get no errors. If I rename a.config.js to a.confi.js (and modify the javascript include to match, I get no error. I don't understand this at all.
What does the browser see when it requests a.config.js? Maybe there is some URL rewriting involved.
You're probably getting a 404. Make sure you put the a.config.js
file in the right place (in the same directory as the html file).
精彩评论