JavaScript

Uploading file using ajax

Uploading file using ajax

27.09.20
Let's upload a file to the server using ajax. Let's use axios. let formData = new FormData(), input = document.getElementById('file'); //"file" - key on server formData.append("file", input.files[0]); ...
Download file using ajax

Download file using ajax

08.06.20
The task of downloading a file using ajax may be more difficult than it seems at first glance. First option Send the file as base64. Substitute the href attribute. And programmatically click on the link.There may be ...
How to determine the direction of scroll on the page?

How to determine the direction of scroll on the page?

05.04.20
Using jQuery, you can do this: let lastScrollTop = 0; $(window).on('scroll', function(){ let top = $(this).scrollTop(); if (lastScrollTop > top) { console.log('top'); } else if (lastScr...
How to detect the operating system using javascript

How to detect the operating system using javascript

06.03.20
Sometimes it is necessary to determine the user's operating system. Example: Your OS is your os function detectOS() { const platform = navigator.platform.toLowerCase(), iosPlatforms = ['iphone', 'ipad'...
Work with cookies in JavaScript

Work with cookies in JavaScript

29.02.20
Сookie (web cookie or browser cookie) is a string of information that can be stored in a browser and sent to the server. The maximum size for one cookie is 4096 bytes. The number of cookies for one domain can be from ...
[12 3 4 5  >>