How can I use Json Jquery in api.openweathermap to get weather information

后端 未结 2 1507
青春惊慌失措
青春惊慌失措 2020-12-21 08:37

I have this api

 http://api.openweathermap.org/data/2.5/forecast/daily?q=Montpellier&mode=json&units=metric&cnt=10 

and I will

2条回答
  •  旧时难觅i
    2020-12-21 09:10

    Just issue ajax GET request:

    var url = "http://api.openweathermap.org/data/2.5/forecast/daily?q=Montpellier&mode=json&units=metric&cnt=10"
    
    $.getJSON(url).then(function(data) {
        console.log(data);
    });
    

    api.openweathermap.org implements CORS, which means that you will not have cross domain issues and can simply request API with AJAX.

提交回复
热议问题