<form method="post" class="auth-form">
<input type="text" name="login" placeholder="login" id="login">
<input type="password" name="password" placeholder="password" id="password">
<button id="submitBtn">Send</button>
</form>
const submitBtnElem = document.getElementById('submitBtn');
if(submitBtnElem) {
submitBtnElem.addEventListener('click', auth(e));
}
function auth(e) {
e.preventDefault();
const login = document.getElementById('login').value;
const password = document.getElementById('password').value;
const xhr = new XMLHttpRequest();
xhr.open("POST", "auth_request", true);
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (this.readyState != 4) return;
console.log( this.responseText );
}
xhr.send(`login=${login}&password=${password}`);
}
<a id="form-submitter" href="form2.php">Go to form 2</a>
$('#form-submitter').click(function(e){
e.preventDefault();
$.ajax({
url: 'form1.php',
success: function(){
window.location.href = "form2.php";
},
error: function(){
alert('failure');
}
});
});
$(".mediaSld .item").click(function() {
console.log('0');
var album_id = $(this).data('id');
$.post(
"",
{
'album_id': album_id
},
function (resp) {
console.log(resp);
$('#popUpSlider').html(resp);
$(".popUpSld").fadeIn(600);
$('#popUpSlider').trigger('destroy.owl.carousel').removeClass('owl-carousel owl-loaded');
$('#popUpSlider').find('.owl-stage-outer').children().unwrap();
$("#popUpSlider").owlCarousel({
loop: true,
margin: 20,
nav:true,
items:3,
navText: ['<img src="../site/templates/image/leftBlack.svg" alt="">', '<img src="../site/templates/image/rightBlack.svg" alt="">'],
responsive: {
0: {
items: 1
},
320: {
items:1,
},
767: {
items: 2,
margin: 10
},
991: {
items: 3,
},
}
});
}
);
});