I am trying to display contents of a json file which has 5 entries as the usual key value pairs, however I currently can only get the Name value to display as intended, the other values are registered literally as a direct return of the in put code. The getJSON
method is to start after a button with id of #json
is clicked. Its working but only displays the first item with the rest being output literally.
The code is below:
jQuery(document).ready(function($) {
$(document).on('click', '#json', function(event) {
event.preventDefault();
var items;
$.getJSON('somedata.json', function(data) {
items = data;
console.log(items['Name'], ['Phone'], ['Mphone'], ['Email'], ['Message']);
});
});
});
Tips welcome ! Thanks