Unexpected end of JSON input
делаю AJAX-валидацию формы на JQuery и скрипт на PHP. Обработчик формы и запрос AJAX посылаю на файл signin.php, откуда должен возвращаться массив $response, однако выдает ошибку SyntaxError:Unexpected end of JSON input
Не знаю как исправить, нужно помощь, пожалуйста Репозиторий со всем кодом тут: https://github.com/Annikangl/testovoe
Файл script.js
$('.submitButton').click(function(e) {
e.preventDefault();
let email = $('input[name="email"]').val();
let login = $('input[name="username"]').val();
$.ajax({
url: 'signin.php',
type: 'post',
dataType: 'json',
data: {
email: email,
login: login,
},
success: function(response) {
if (response.status == 1) {
document.location.href('users.php');
}
},
error: function(xhr, status, error) {
alert(xhr.responseText + '|\n' + status + '|\n' +error);
}
});
});
Файл-обработчик формы: signin.php
<?php
session_start();
require_once "includes/config.php";
require_once "includes/Constants.php";
require_once "includes/Account.php";
$auth = new Account($con);
if (isset($_POST['submitButton'])) {
$email = $_POST['email'];
$username = $_POST['username'];
$singIn = $auth->login($email,$username);
if ($singIn) {
$response = array(
'status' => true
);
json_encode($response);
}
}
?>
Сама форма:
<?php
include "signin.php";
?>
<!DOCTYPE html>
<html lang="ru">
<head>
<title>Авторизация</title>
<link rel="stylesheet" href="assets/style/style.css">
</head>
<body>
<!-- Авторизация -->
<form>
<h2>Авторизация</h2>
<?= $auth->getError(Constants::$invalidData); ?>
<label for="email">Введите email</label>
<?php echo $auth->getError(Constants::$emailValidate); ?>
<input type="email" name="email">
<label for="name">Логин</label>
<?php echo $auth->getError(Constants::$usernameValidate); ?>
<input type="text" name="username">
<button class="submitButton" type="submit" name="submitButton">Войти</button>
<p>Нет аккаунта? <a href="register.php">Регистрация</a></p>
</form>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"
integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0="
crossorigin="anonymous"></script>
<script src="assets/js/script.js"></script>
</body>
</html>