I am trying to send an ajax request using the below code but I keep getting an Error 0 message. I am pretty sure the url is valid but I just wondered if the code is ok as I am trying this for the first time, altering a template provided by a tutor. Any advice gratefully received.
$('#submitOne').click(function() {
$.ajax({
url: "http://localhost/alistairJenkins/task/php/getCountryCode.php",
type: 'POST',
dataType: 'json',
data: {
lat: $('#latOne').val(),
lng: $('#lngOne').val()
}})
.done(function(result) {
console.log(result);
if (result.status.name == "ok") {
$('#txtResult').html(result['data']);
}
})
.fail(function(jqXHR, textStatus, errorThrown) {
var errorMsg = jqXHR.status + ' : ' + textStatus + errorThrown;
alert("Error - " + errorMsg);
})
})