Fill HTML dropdown box with external JSON file data

后端 未结 4 537
甜味超标
甜味超标 2021-01-27 21:28

I am trying to fill a HTML Dropdown menu with data from an external JSON file, which contains the following

{
    \"Destinations\": [
    {
        \"destinatio         


        
4条回答
  •  耶瑟儿~
    2021-01-27 22:01

    Use each and append select like this:

    $.each(data.Destinations, function(i, v) {
        $('#destinations').append('');
    });
    

    jsFiddle

    Updated Example (test.html for http://jonathangatenby.co.uk/Candidate/json/destinations.json)

    
    Fetch JSON
    
    
    
    

    Example to work make sure html file or the file from which you are making the ajax call are on same domain (jonathangatenby.co.uk)

提交回复
热议问题