$('#btn-shorten').on('click', function(){ $.ajax({ url: '/api/v1/shorten', type: 'POST', dataType: 'JSON', data: {url: $('#url-field').val()}, success: function(data){ const $link = $('#link'); const resultHTML = `${data.shortUrl}`; $link.html(resultHTML); // $link.hide().fadeIn('slow'); $link.hide().show(); } }); }); (function($) { $.extend($.fn, { fadeIn: function(ms) { if(typeof(ms) === 'undefined') ms = 500; $(this).css({ display: 'block', opacity: 0 }).animate({ opacity: 1 }, ms); return this; }, fadeOut: function(ms) { if(typeof(ms) === 'undefined') ms = 500; $(this).css({ opacity: 1 }).animate({ opacity: 0 }, ms, 'linear', function() { $(this).css('display', 'none'); }); return this; } }); })(Zepto);