function btnFind() { // Reset Rows $("#alertBox").hide(); $(".alert").html(""); $('.alert').removeClass('alert-warning').removeClass('alert-danger').addClass('alert-warning'); $("#spinnerBox").hide(); $("#txtOutput").hide(); // Set Vars let txtAddress = $("#txtAddress").val() + ""; // Quick test to make sure address was entered. if (txtAddress === "") { $(".alert").html("You have to enter an address first."); $("#alertBox").show(); return; } // Show Spinner $("#spinnerBox").show(); // API - Call geocode API // K = (Required) Key, allows access to API // C = (Required) Command, // LL - Will return the Lat/Lon of a given address. // DIST - Will return the distance information. // T = (Optional) Test, Test Mode = 1 will only pull one record from the DB // ADDRESS = Address you want to return the Lat/Lon or Distance from. $.ajax( { url : 'https://rhays.us/Examples/RX_API_Two/RX2.php', type : 'GET', dataType: 'json', data : { 'K' : 'RLH4321', 'C' : 'DIST', 'T' : '0', 'address' : txtAddress, }, success : function(data) { switch(data.status.toUpperCase()) { case 'OK': sOutput = '

The Pharmacy closest to the address location you entered is:

'; sOutput = sOutput + 'Pharmacy: ' + data.pharmacy + '
'; sOutput = sOutput + 'Address: ' + data.address + '
'; sOutput = sOutput + 'City: ' + data.city + '
'; sOutput = sOutput + 'State: ' + data.state + '
'; sOutput = sOutput + 'Zip: ' + data.zip + '

'; sOutput = sOutput + '

Approx. Drive time and distance:

'; sOutput = sOutput + 'Distance: ' + data.distance + '
'; sOutput = sOutput + 'Duration: ' + data.duration + '
'; $("#txtOutput").html(sOutput); $("#spinnerBox").hide(); $("#txtOutput").show(); break; case 'ERROR': $("#spinnerBox").hide(); $('.alert').removeClass('alert-warning').removeClass('alert-danger').addClass('alert-danger'); $(".alert").html(JSON.stringify('Error code: ' + data.code + ' - ' + data.description)); $("#alertBox").show(); break; } }, error : function(request,error) { $("#spinnerBox").hide(); $('.alert').removeClass('alert-warning').removeClass('alert-danger').addClass('alert-danger'); $(".alert").html('SYSTEM.JS
' + JSON.stringify(request)); $("#alertBox").show(); return; }, // TODO: Hook to put in status codes // statusCode: // { // 404: function() { // alert( "page not found" ); // } // }, }); }