how to use ajax to get temperature with address code example

Example: how to use ajax to get temperature with address

$.ready(
                $.ajax({
                    method: "GET",
                    url: "https://api.openweathermap.org/data/2.5/weather",
                    data: {
                        appid: {your API key},
                        q: {city name},
                        units: "metric" //for undrestandable units like C,mph,...
                    },
                    dataType: 'json',
                    success: function (data) {
                        alert("success");
                        console.log(data); //for seeing the object details in the console
                    },
                    error: function () {
                        alert("error");
                    }
                }));

Tags:

Misc Example