I'm very new to AJAX and I'm trying to use console.log data from a JSON file. I have two <input type="number"> elements and one <select> element in my HTML file, for latitude, longitude and language, and I have given the number elements default values, e.g. <input type="number" id="latitude" name="latitude" value="61.9820" min="-90" max="90" step="0.0001">. The button has an id of "btn".
$('#btn').click(function() {
console.log('timezone is pressed');
$.ajax({
url: "timezone.php",
type: 'POST',
dataType: 'json',
data: JSON.stringify({
lat: $('#lat').val(),
lng: $('#lng').val(),
lang: $('#lang').val()
}),
success: function(result) {
console.log(result);
}
});
});
The first console.log statement prints but the stringified JSON does not. I have looked at W3Schools, read the documentation and looked at an example which I'm trying to follow and I can't find where I'm going wrong