I am struggling with a basic set of HTML and JS files that are not functioning properly, and I can't seem to pinpoint the issue:
<html>
<head>
<script type="text/javascript" src="data.json"></script>
</head>
<body>
</body>
</html>
var data = '{"name" : "Phil Powell"}';
alert(data + ' ' + data.name + ' ' + data.type);
Every time I attempt to open this setup, I consistently encounter the same error message:
{"name" : "Phil Powell"} undefined undefined
I can't understand what I'm doing incorrectly. My goal is simply to parse an external JSON file, but I cannot achieve it.
Your assistance would be greatly appreciated.
Thank you