I have some code that I need help with. I have a database with a list of abbreviations with is encoded into JSON in a PHP script, the script below pulls in that data and stores the data as objects (or thats how I want it to be).
$("#load_abbr_data").click(function() { var abbrs = {} $.getJSON("jsondata.php",function(data) { $.each(data.abbr_data, function(i,get_abbr_data) { var abbr = get_abbr_data.ABBR; var desc = get_abbr_data.DESCRIPTION; var lang = get_abbr_data.LANG; abbrs = { abbr : [desc], } }); }); }); So I would like the resulting object to look like: var abbrs = { HTML : [ 'HyperText Markup Language'] , PHP: 'Personal Home Page' } But I don't think it does (or at least it only saves the last record). And have this script run: var somevar = "PHP"; for( var i = 0 ; i < abbrs[somevar].length; i++) { var expanded = abbrs[somevar]; } alert( somevar + " is short for " + expanded ); But the problem is I can't get it to save as the example object. And when I run the above script nothing works. Could I please have some help in getting the JSON script working please.