<section>
<h3>РЕЗУЛЬТАТЫ ОГЭ/ГВЭ</h3>
<p>Выберите ваш регион:</p>
<form method="post">
<select name="region">
<option value="0">Не выбран</option>
<option value="saratov">Саратов</option>
</select>
</form>
</section>
<script>
$('select').on('change', function() {
$.ajax({
type: 'POST',
url: '<?=$_SERVER["PHP_SELF"]?>',
data: ({region: $(this).val()})
});
});
</script>
<?
$selected_val = $_POST['region']; // Storing Selected Value In Variable
echo $selected_val; // Displaying Selected Value
?>
//Подгрузка страниц в селектор
$('#subject').on('change', function() {
var SubjectCode = $('select#subject option:selected').val();
$.post("http://sarrcoko.ru/ajax/get_date_by_exam.php", {
SubjectCode: SubjectCode
}, onAjaxSuccess);
function onAjaxSuccess(data) {
$('#examdate').html(data);
setTimeout(function() {
$('input, select').trigger('refresh');
}, 1)
}
});
Access to XMLHttpRequest at 'http://sarrcoko.ru/ajax/get_date_by_exam.php' from origin 'МОЙ_САЙТ' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
function parentPush($array, $key , $parent = null){
$result = [];
foreach ($array as $k => $v) {
if(isset($v[$key])){
if ($parent)
$v[$key]['code_parent'] = $parent;
$result[] = array_diff_key($v[$key], array_flip(['category']));
}
if (isset($v["code"]))
$parent = $v["code"];
$m = is_array($v)? parentPush($v, $key, $parent) : null;
$result = is_array($v)? array_merge_recursive($result, $m) : $result;
}
return $result;
}
$result = parentPush($getSection, "@attributes");
print_r($result);