简体   繁体   中英

HTML - Include Javascript in parent directory

I have a HTML page and I am trying to include some js files like

<script type="text/javascript" src="../bower_components/jquery/jquery.js"></script>

But I keep getting

Resource interpreted as Script but transferred with MIME type text/html: "http://localhost:8080/bower_components/jquery/jquery.js".

followed by

Uncaught SyntaxError: Unexpected token < jquery.js:1

in the developer console. I am trying some tutorials on angular.js and node.js

Solved https://stackoverflow.com/a/21823343/1451512

You're including ../bower_components/jquery/jquery.js as a script, so the browser tries to interpret as a script. The reason it finds a < is probably because the server can't find a file at that path, and so it returns a 404.

To make sure this is the case, open the developer tools of your browser of choice. Most, if not all browsers have a way to see the requests and their responses. In chrome, you can do this by opening the dev tools and clicking the network tab.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM