var path = window.location.href.replace('index.html', ''); var jsonFile = path + "menus/" + menuc + ".json"; $.getJSON(jsonFile, function(result) { sortAllergies(result); });