keep the countries list in countries.json file. If load the countries into the combo box from json file, no result is coming here is thee code details. while loading the page the countries should on the combo box.
countries.json
[
{name: 'Afghanistan', code: 'AF'},
{name: 'Ã…land Islands', code: 'AX'},
{name: 'Albania', code: 'AL'},
{name: 'Algeria', code: 'DZ'},
{name: 'American Samoa', code: 'AS'},
{name: 'AndorrA', code: 'AD'},
{name: 'Angola', code: 'AO'},
{name: 'Anguilla', code: 'AI'},
{name: 'Antarctica', code: 'AQ'},
{name: 'Antigua and Barbuda', code: 'AG'},
{name: 'Argentina', code: 'AR'},
{name: 'Armenia', code: 'AM'},
{name: 'Aruba', code: 'AW'},
{name: 'Australia', code: 'AU'},
{name: 'Austria', code: 'AT'},
{name: 'Azerbaijan', code: 'AZ'},
{name: 'Bahamas', code: 'BS'},
{name: 'Bahrain', code: 'BH'},
{name: 'Bangladesh', code: 'BD'},
{name: 'Barbados', code: 'BB'},
{name: 'Belarus', code: 'BY'},
{name: 'Belgium', code: 'BE'}
]
Html File -demo.html
<!doctype html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
</head>
<body>
<select id="orgcountry" class="form-control input-md"></select>
<script>
$(document).ready(function() {
var $select = $('#orgcountry');
$.getJSON('countries.json', function(data) {
$select.html('');
//iterate over the data and append a select option
$.each(data, function(key, val){
$select.append('<option id="' + val.code+ '">' + val.name + '</option>');
})
});
});
</script>
</body>
</html>