Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(function() {
- // variables for DOM
- var $select = $("select");
- var $h1 = $("h1");
- //variables for url
- var holidayUrl = 'https://holidayapi.com/v1/holidays?key=dba66ef9-c647-4829-9f65-71d0279eed85&country=PL&year=2016';
- function insert(holidays) {
- $.each(holidays, function(i, holiday) {
- var option = $('<option name = ${"holidays.name"}>holiday.date</option>')
- /* poprawnie */
- var option = $(`<option name = ${holidays.name}>${holiday.date}</option>`)
- $h1.text('ΕwiΔta w Polsce w 2016 roku');
- $select.append(option);
- $('div').append($h1);
- })
- }
- function loadHolidays() {
- $.ajax({
- url: holidayUrl,
- type: 'get'
- }).done(function(holidays) {
- insert(holidays);
- console.log(holidays);
- }).fail(function(error) {
- console.log(error);
- })
- }
- $select.on('click', function(e) {
- loadHolidays();
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement