GOPAL YADAV GOPAL YADAV - 11 months ago 50
jQuery Question

Unable to load data from local json file using jQuery

<!DOCTYPE html>
<script data-require="jquery@*" data-semver="3.0.0" src=""></script>
<link rel="stylesheet" href="style.css" />
<script type="text/JavaScript">
$select = $('#people');
//request the JSON data and parse into the select element
url: 'simple.json',
//clear the current content of the select
//iterate over the data and append a select option
$.each(data.person, function(key, val){
$select.append('<option >' + val.firstName+ '</option>');
//if there is an error append a 'none available' option
$select.html('<option >none available</option>');

<select id="people"></select>


The data from local json file cannot be read using jQuery ajax.

Even I am trying the same code using
. The output is not being returned.

This is my plunker:


change data.person to data.employees, wrap the code in a document ready statement