Имя: Пароль:
1C
1С v8
HTTP Сервисы на апачи не работают и выдают ошибку 401. Что делать?
0 Dimentor
 
15.03.21
06:58
Пытался создать окно регистрации новых пользователей, а что делать с этой ошибкой ума не приложу
Текст html файла:
<html>

<meta http-equiv="Content-Type" content="text/html; charset-utf-8">

<style type="text/css">
    .block {
position
top:50%;
left:50%;
transform: translate(50%, 50%);
width: 60%;
text-align:center;
    }
    .input-form{
text-align:center;
width: 100%;
padding 10px;
}
    .btn {
background-color:rgb(255,255,0)
font-size: 20px;}
    .btn:active{background-color:rgb(100,255,0)}
</style>
    <div class="block">
<h1>Регистрация в базе</h1>
<input class="input-form" type="text" id="login" placeholder="Введите логин">
<br>
<br>
<input class="input-form" type="text" id="password" placeholder="Введите пароль">
<br>
<br>
<button class="btn" id="registration">Зарегистрироваться</button>
</div>
<script type="text/javascript">
function sendForm(e){
var data={login: document.getElementById("login").value, password: document.getElementById("password").value,}
const request = new XMLHttpRequest();
const url ="http://localhost/nti/hs/CentralService/reg";
request.responseType = "json";
request.open("POST",url,true);
request.setRequestHeader("Authorization","Basic"+btoa("guest"))
request.setRequestHeader("Content-type","application/x-www-form-urlencoded");







request .addEventListener("readystatechange", () => {

if (request.readyState === 4 && request.status === 200) {
let obj = request.response;
console.log(obj);
}
});
console.log(JSON.stringify(data));
request.send(JSON.stringify(data)); //На этой строчке выдает ошибку

}

var registration = document.getElementById("registration") ;
registration.onclick = sendForm
</script>
</html>
1 spiller26
 
15.03.21
08:54
(0) 401 Unauthorized («не авторизован (не представился)»)
2 Asmody
 
15.03.21
09:12
Запомните, дети: когда серверный код действительно "не работает" - это ошибка 50x.
Ошибка 40x означает, что серверный код работает. Только вы не то и не так спрашиваете.
3 программистище
 
15.03.21
09:34
ну значит надо авторизоваться
4 Kesim
 
15.03.21
10:57
(0) пользуй постман
5 eklmn
 
гуру
15.03.21
11:51
продам пробелы
" Basic "