I am new to javascript, need help. I have created a index.html and a app.js (both in same path), and have hosted the index.html as localhost.
When I run individual index.html I do get the hello alert, but when I run using localhost I get "Uncaught SyntaxError: Unexpected token <" error.
Below is the code that i used:
Index.html:
<!DOCTYPE HTML>
<html>
<head>
<title>Show Javascript alert</title>
<script type="text/javascript" src="app.js"></script>
</head>
<body>
</body>
</html>
app.js:
function display_alert(){
alert("Hello!");
}
window.onload = display_alert;