37 lines
1.0 KiB
JavaScript
37 lines
1.0 KiB
JavaScript
function SendLoginForm(el){
|
|
|
|
event.preventDefault()
|
|
let form = el.form;
|
|
let formData = new FormData(form);
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
headers: { "X-CSRFToken": $('input[name=csrfmiddlewaretoken]').val() },
|
|
url: '/ru/user_account/login/',
|
|
type: "POST",
|
|
// async: true,
|
|
cache: false,
|
|
processData: false,
|
|
contentType: false,
|
|
// enctype: 'json',
|
|
data: formData,
|
|
success: function(data){
|
|
|
|
location.href = '/profile'
|
|
// let profile_btn = document.createElement("a");
|
|
// profile_btn.classList.add("profile_button");
|
|
// profile_btn.innerText = "Профиль";
|
|
// let reg_btn = document.querySelector(".registration_button");
|
|
// let replace_btn = reg_btn.parentNode;
|
|
// replace_btn.replaceChild(profile_btn, reg_btn);
|
|
|
|
},
|
|
error: function (data, exception){
|
|
document.querySelector(".login").innerHTML = data.responseJSON.html
|
|
}
|
|
});
|
|
}
|
|
|