Use visual studio code to write the javascript programme.
For this lab you must use a reasonable faceted search example, each item must have at least three categorical attributes and at least one numeric attribute. Attributes such as ID, name etc do not count as categorical or numeric attributes.
(a) Define a class for your item that meets the above three categorical and one numeric attribute requirements.
(b) Create a text file that contains at least 5 such records in CSV format.
(c) Create a HTML page that contains a table element the shows one item record (hardcoded in the HTML).
(d) Add a script element into your HTML page that prints ‘hello’ to the browser’s JavaScript developer console.
(e) Add JavaScript code that uses ‘fetch’ into your HTML page that loads your item text file. Use a python initiated local server to serve that text file.
Author: Rishabh Jain
Date:08/09/2019
<html>
<head>
<body>
<table>
<tr>
<th>Industry Type</th>
<th>Occupational Safety and Health</th>
<th>Sources of Hazards</th>
<th>Scale of Workers</th>
</tr>
<tr>
<td>Chemical</td>
<td>General</td>
<td>Acid</td>
<td>200</td>
</tr>
</table>
<script>
console.log("Hello");
url='' //enter your url
let response = fetch(url);
if (response.ok) { // if HTTP-status is 200-299
// get the response body (the method explained below)
let json = response.json();
} else {
alert("HTTP-Error: " + response.status);
}
console.log(response)
</script>
</body>
</head>
</html>
Get Answers For Free
Most questions answered within 1 hours.