Comparison of jQuery getJSON and ajax.
I tried to debug this code in jQuery(the following), the object is to get the data from a json file and re-format the output data into an array, this array will be used in others functions later.
$(document).ready(function() { var arr = []; // Get data from a json file $.getJSON("jsonfile.json", {}, function(data) { $.each(data, function(key, value) { arr.push(value); // Add data value to an array }); }); console.log(arr); // Print the array to console });