Try thisone: http://jsfiddle.net/qaczD/2/
// populate <select> with available choices
$.getJSON('http://dl.dropboxusercontent.com/u/48552248/websites/timewasted/new/industries.json', function (data) {
$.each(data.sectors, function (i, sector) {
$.each(sector.subsectors, function (i, subsector) {
var optGroup=$('<optgroup />').attr('label','#' + subsector.title).appendTo('.js-industries-select');
$.each(subsector.industries, function (i, industry) {
// if (industry.name.search(regex) != -1) {
$(optGroup).append( $('<option />').html(industry.name));
// }
})
});
});
console.log('yes');
});
// call chosen plugin that prettifies the Industry options
setTimeout(function() {$(".js-industries-select").chosen({
placeholder_text_multiple: 'e.g. Retail banking…'
});}, 1000);