I need some help and advice if possible.
I'm working on a task for an online course and I'm stumped. I have the below html, trying to send a latitude value to ajax for a php request to geonames API and return the nearest ocean. I have tried a couple of different ways as shown below in the html code.
<select id="latitude">
<option value= "3.4360">3.4360</option>
<option value="lat">133.7751</option>
<option value="lat">106.3468</option>
</select>
<select id="longitude">
<option value= 55.3781>55.3781</option>
<option value="lng">25.2744</option>
<option value="lng">56.1304</option>
</select>
And this is the ajax request that should be pulling the info from the above html.
$('#btnRun').click(function() {
$.ajax({
url: "libs/php/getCountryInfo.php",
type: 'POST',
dataType: 'json',
data: {
lat: parseInt($('#latitude').val()),
lng: parseInt($('#longitude').val())
},
success: function(result) {
console.log(JSON.stringify(result));
if (result.status.name == "ok") {
$('#txtDistance').html(result['data'][0]['distance']);
$('#txtGeonameID').html(result['data'][0]['geonameid']);
$('#txtName').html(result['data'][0]['name']);
}
},
error: function(jqXHR, textStatus, errorThrown) {
// your error code
}
});
});
I don't think the two link up at all and I had a look at the parseInt option as well but I am out of ideas now.
Thank you for any help you can give.