Answer the question
In order to leave comments, you need to log in
Why doesn't AJAX call the script unless it's in the root of the site?
Actually, I ran into a problem. It is necessary to implement an entrance to the site. I made an AJAX call to the script on passport.php, but the problem is that it became necessary to create AJAX actions in a separate actions folder. But suddenly, for some reason, if I add a folder, it is stupidly not executed.
Where is the AJAX called from:
$(document).ready(function () {
$('body').on('submit', '#passport', function (e) {
e.preventDefault();
$.ajax({
url: '/actions/passport.action.php',
method: 'post',
dataType: 'html',
data: $(this).serialize(),
success: function (data) {
if (data == 'false') {
Lobibox.notify('error', {
delay: 2000,
title: 'Oops',
msg: 'Неверный логин или пароль.'
});
}
if (data == 'true') {
window.location.replace('/index.php');
}
}
});
});
});
<?php
$hasLoginSet = isset($_POST['login']);
$hasPasswordSet = isset($_POST['password']);
if ($hasLoginSet and $hasPasswordSet) {
$conf = parse_ini_file('conf.ini');
if ($conf['login'] == $_POST['login'] and $conf['password'] == $_POST['password']) {
setcookie('remix', $conf['remix']);
echo 'true';
} else {
echo 'false';
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question