Сообщение от Rise
|
покажи
|
function signUp() {
document.querySelector('#regBtn').addEventListener('click', function () {
var newName = document.getElementById("newName").value;
var newPass = document.getElementById("newPass").value;
var registration = 'username=' + newName + '&password=' + newPass;
var xhrRegistration = new XMLHttpRequest();
xhrRegistration.open('POST', 'http://smktesting.herokuapp.com/api/register/', true);
xhrRegistration.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xhrRegistration.setRequestHeader('Accept', "application/json");
xhrRegistration.onreadystatechange = function () {
if (this.readyState === 4) {
xhrRegistration.onload = function () {
gsonProductComments3 = JSON.parse(xhrRegistration.responseText);
if (gsonProductComments3.success === true) {
alert("Successful registration! Now Log In");
$("#modalReg").modal("hide");
}
else {
var registrationValid = document.querySelector(".validRegistration");
registrationValid.className = "validRegistration";
}
};
}
};
xhrRegistration.send(registration);
});
}
signUp();