Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict';
- $(document).ready(function () {
- var $submit = $("#submit"),
- $city = $("#city");
- $submit.on("click", function () {
- // wysyłamy żądanie pod url opisany w dokumentacji http://www.apixu.com/doc/
- $.ajax({
- url: `http://api.apixu.com/v1/current.json?key=298458f3e7fc426bacc84203170502&q=${$city.val()}`,
- type: "get"
- }).done(function (weather) {
- // po odebraniu danych wywyoła się funkcja done()
- console.log(weather);
- var $newP = $("<p>"),
- text = `Weather in ${weather.location.name}, ${weather.location.country}: Temp: ${weather.current.temp_c}, Clouds: ${weather.current.cloud}, Pressure: ${weather.current.pressure_mb}`;
- $newP.text(text);
- $newP.appendTo($("body"));
- }).fail(function (error) {
- console.error(error);
- })
- })
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement