I'm trying to take some data from my javascript file and put it into new rows and columns in my html file. I think the problem might have to do with my script closing before the table in my html file. I currently have a table in my html file that looks like this:
<div id="map" style="width: 700px; height: 700px"></div>
<script src="js/mapping.js"></script>
<div id="tablebody">
<p>
<b>List of Nearby Locations</b>
</p>
<table class="table table-stripped">
<tbody>
<tr>
<th>Name</th>
<th>Address</th>
</tr>
<tr>
<td>John Smith</td>
<td>1500 Pennsylvania Ave</td>
</tr>
</tbody>
</table>
</div>
and JS code that looks like this:
service = new google.maps.places.PlacesService(map);
service.nearbySearch(request, callback);
function callback(results, status) {
if (status == google.maps.places.PlacesServiceStatus.OK) {
for (var i = 0; i < results.length; i++) {
createMarker(results[i]);
alert("name: " + results[i].name + ", Address:" + results[i].vicinity);
$('#tablebody tr:last').after('<tr>"Name: " + results[i].name + ", Address: " + results[i].vicinity</tr>');
}
}
}