JSON data not loading via jquery getJSON
I’m feeling silly here, but for the life of me I can’t find out what’s going on.
I’m trying to fill in a dropdown based on the value of another dropdown. I’ve done this about a million times before, but the JSON just doesn’t want to load into the dropdown. It actually looks like it’s just skipping the getJSON entirely.
Any ideas?
var url = "http://lostpetposters.org/json/dogs.json";
function populateDropdown(url) {
$("#animalBreed").attr('disabled', false);
$("#animalBreed").empty();
$("#animalBreed").append('<option selected="true" disabled></option>');
$.getJSON(url, function (data) {
console.log(data)
$.each(data, function (key, entry) {
$('#animalBreed').append($('<option></option>').attr('value', entry.name).text(entry.name));
})
});
}
A fiddle to play with
jsfiddle.net/zazvorniki/dpzt8sve/12/
Read more here: Source link