Is there any way I can use GET and POST methods in JavaScript like in PHP? Of course, I could echo javascript code in script tags using PHP, but in my case that's impossible...
XMLHttpRequest is what you need. It is a native way to communicate with a server.
Also, thanks to @charlietfl, more modern approach is to use fetch, but its not supported in IE.