I'm trying to show an 'alert' box with text from JSON file in it. But it seems like I can't get data from my JSON file. It just doesn't throw an alert box.
var thebook = JSON.parse(book);
function showAlert() {
alert(thebook[0].word);
}
<head>
<script type="text/javascript" src="book.json"></script>
</head>
<body>
<button onclick="showAlert()">show alert</button>
</body>
And an example JSON file
[
{
"word" : "cuiller",
"page" : 23
},
{
"word" : "arbre ",
"page" : 245
}
]