asked on February 16, 2018
Good afternoon,
We have been looking into adding fucntionality to our Forms that would allow calling an API via JQUERY in a forms Javascript.
We have found some outside examples of performing this, below is an example:
$(document).ready(function() { $('#weatherLocation').click(function() { let city = $('#location').val(); $('#location').val(""); $.ajax({ url: `http://api.openweathermap.org/data/2.5/weather?q=${city}&appid=[API-KEY-GOES-HERE]`, type: 'GET', data: { format: 'json' }, success: function(response) { $('.showHumidity').text(`The humidity in ${city} is ${response.main.humidity}%`); $('.showTemp').text(`The temperature in Kelvins is ${response.main.temp}.`); }, error: function() { $('#errors').text("There was an error processing your request. Please try again.") } }); }); });
Has anyone found/done anything different in their forms javascript that differs from what is being portrayed above?
Any suggestions would be greatly appreciated.
Thanks!
0
0