Why is the results array showing as undefined?
I am having trouble displaying the objects inside the results array. I have attempted to do so with console.log(data.results[0].bodyColor) but encountered an error. When I try accessing (data.results), it returns undefined. Even trying (data.results[0]) triggers an error message. It's perplexing why the array appears as undefined when I can clearly see it in my console. How can I print out the value of AirBagLocFront from this array?
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
</head>
<body>
<h2> Vehicle API</h2>
<div id="div"></div>
<script src="https://code.jquery.com/jquery-3.2.1.js" integrity="sha256-DZAnKJ/6XZ9si04Hgrsxu/8s717jcIzLy3oi35EouyE=" crossorigin="anonymous"></script>
<!--Jquery CDN-->
<script>
$.ajax({
url: "https://vpic.nhtsa.dot.gov/api/vehicles/DecodeVINValuesBatch/",
type: "POST",
cache: true,
data: {
format: "json",
data: "WBAPK5C52AA599960;"
},
dataType: "json",
success: function(data) {
console.log(data.results[0].AirBagLocFront);
}
});
</script>
</body>
</html>