Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const paragErrore = document.querySelector('#errore-log-in');
- const bottoneSubmit = document.querySelector('#submit-btn');
- // console.log(InputPasswordLogIn);
- bottoneSubmit.addEventListener('click', function(event){
- event.preventDefault();
- const InputUserNameLogIn = document.querySelector('#username');
- const InputPasswordLogIn = document.querySelector('#password');
- const richiesta = new XMLHttpRequest();
- richiesta.open('POST', 'http://localhost/vsc/php/log-in.php', true);
- richiesta.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- richiesta.onreadystatechange = function () {
- if (richiesta.readyState === 4) {
- if (richiesta.status === 200) {
- console.log(richiesta.responseText);
- } else {
- console.error('Errore durante la richiesta. Codice di stato:', richiesta.status);
- }
- }
- };
- const data = "username=" + encodeURIComponent(InputUserNameLogIn) + "&password=" + encodeURIComponent(InputPasswordLogIn);
- richiesta.send(data);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement