You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.3 KiB
54 lines
1.3 KiB
let value_error = false; // Flag if Lat/Lon values are out of range.
|
|
let latitude_low = 38.0;
|
|
let latitude_high = 40.0;
|
|
let longitude_low = -97.0;
|
|
let longitude_high = -94.0;
|
|
|
|
function submitForm()
|
|
{
|
|
// Clear values
|
|
value_error = false;
|
|
$("#latitude_error").html('');
|
|
$("#longitude_error").html('');
|
|
// Set Vars
|
|
let nLatitude = $("#latitude").val();
|
|
let nLongitude = $("#longitude").val();
|
|
|
|
if ((!$.isNumeric(nLatitude)) || (!inRange(nLatitude,latitude_low,latitude_high)))
|
|
{
|
|
$("#latitude_error").html('Please enter a value between ' + latitude_low + ' and ' + latitude_high);
|
|
value_error = true;
|
|
}
|
|
|
|
if ((!$.isNumeric(nLongitude)) || (!inRange(nLongitude,longitude_low,longitude_high)))
|
|
{
|
|
$("#longitude_error").html('Please enter a value between ' + longitude_low + ' and ' + longitude_high);
|
|
value_error = true;
|
|
}
|
|
|
|
// if Lat or Lon values are out of range return to form.
|
|
if (value_error) { return; }
|
|
|
|
// Call to API
|
|
$.ajax(
|
|
{
|
|
url : 'https://rhays.us/Examples/RX_API_Call/RX.php',
|
|
type : 'GET',
|
|
dataType: 'html',
|
|
data :
|
|
{
|
|
'K' : 'RLH1234',
|
|
'Latitude' : nLatitude,
|
|
'Longitude' : nLongitude
|
|
},
|
|
success : function(data)
|
|
{
|
|
$("#results").html(data);
|
|
},
|
|
error : function(request,error)
|
|
{
|
|
alert("Request: "+JSON.stringify(request));
|
|
}
|
|
});
|
|
|
|
}
|
|
|