I am trying to call a variable in JSON that is inside an array , I want that when people search a city a modal will appear in the screen, the modal appeared but the value wont load the structure of JSON is
"title": "",
"start": "",
"tags": "",
"imageurl": "",
"products": [
{
"name":"this is the value I want to call",
"url": "",
"time":"",
"location":""
}
]
$("#search").change(function () {
var selectedCity = $("#searchcity").val();
$.getJSON('events.json',
function (data) {
render(selectedCity, data);
});
});
function render(selectedCity, data) {
$(".order-details-table").empty();
$(data).each(function (i, v) {
if (selectedCity == 'all' || v.products.name == selectedcity) {
if (v.products)
$(v.products).each(function (index, p) {
$(".order-details-table").append('<tr><td class="o-box-name"><a name="detailsevent">' + p.name + '</a></td><td class="o-box-name">' + v.title + '<br><small>' + p.time + '</small><small> ' + p.location + '</small></td><td><a href="' + p.url + '" class="cancel-del-text" target=_"blank">Register!</a></td></tr>');
});
}
});
}
html
<p><span> Filter by City: </span><select id="searchcity" class="modal-trigger" name="searchcity" data-modal="modal-name">
<option selected="selected" value="select">Select a City</option>
<option value="chicago">Chicago</option>
<option value="denver">Denver</option>
<option value="all">All</option>
</select></p>