Есть зависимые списки
<?php
session_start();
require_once('./assets/config/config.php');
require_once('ayth/check.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/css/font-awesome.min.css">
<link rel="stylesheet" href="assets/css/style.css">
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
<title>Личный кабинет Russian Gamers</title>
</head>
<body>
<?php require_once('assets/requiure/navbar.php');?>
<div class="container">
<div class="row">
<div class="col-lg-8 mx-auto text-center login_success">
<form action="#" method="get">
Страна:
<select name="game_id" id="game_id" class="StyleSelectBox">
<option value="0">- Выберите игру -</option>
<option value="3">Minecraft</option>
<option value="9908">Garry's Mod</option>
<option value="248">CS:GO</option>
</select><br>
Регион:
<select name="region_id" id="region_id" disabled="disabled" class="StyleSelectBox">
<option value="0">- Выберите Привелегию -</option>
</select>
</form>
</div>
</div>
</div>
<?php require_once('assets/requiure/modal.php'); require_once('assets/requiure/script.php'); ?>
<script src="assets/js/selects.js"></script>
</body>
</html>
После выбора игры происходит вечная загрузка
Вот js:
$(document).ready(function () {
$('#game_id').change(function () {
var game_id = $(this).val();
if (game_id == '0') {
$('#region_id').html('<option>- Выберите Привелегию -</option>');
$('#region_id').attr('disabled', true);
return(false);
}
$('#region_id').attr('disabled', true);
$('#region_id').html('<option>загрузка...</option>');
var url = 'assets/lib/select/get_privilege.php';
$.get(
url,
"game_id=" + game_id,
function (result) {
if (result.type == 'error') {
alert('error');
return(false);
}
else {
var options = '';
$(result.regions).each(function() {
options += '<option value="' + $(this).attr('region_id') + '">' + $(this).attr('name') + '</option>';
});
$('#region_id').html('<option value="0">- Выберите Привелегию -</option>'+options);
$('#region_id').attr('disabled', false);
}
},
"json"
);
});
});
и back-end:
<?php
header("Content-Type: text/html; charset=UTF-8");
require_once ('../../config/config.php');
$id_game = @intval($_GET['id_game']);
mysqli_query($connect, "SET NAMES utf8");
$regs=mysqli_query($connect, "SELECT donate, id FROM id_donate WHERE id_game = '$id_game'");
if ($regs) {
$num = mysqli_num_rows($regs);
$i = 0;
while ($i < $num) {
$regions[$i] = mysqli_fetch_assoc($regs);
$i++;
}
$result = array('regions'=>$regions);
}
else {
$result = array('type'=>'error');
}
print json_encode($result, JSON_UNESCAPED_UNICODE);
?>
Ошибку можно увидеть на lk.russian-gamers.ru/donate.php