Проблема в том, что я убираю несколько строк в таблице базы данных с помощью запроса ajax. Когда я пытаюсь убедиться, что обновление прошло успешно, оно возвращается с заголовком 404, я перехожу к сетевым инструментам и вижу404, как показано на скриншоте ниже:
![404 header screenshot](https://i.stack.imgur.com/jYSWH.png)
это код, который у меня есть для js и php
PHP:
<?php
include("../../db_connect.php");
if(isset($_POST['ads_left'])) {
$ads_left = mysqli_real_escape_string($connect , $_POST['ads_left']);
$ads_right = mysqli_real_escape_string($connect , $_POST['ads_right']);
$ads_top = mysqli_real_escape_string($connect , $_POST['ads_top']);
$ads_bottom = mysqli_real_escape_string($connect , $_POST['ads_bottom']);
$ads_left = htmlentities($ads_left);
$ads_right = htmlentities($ads_right);
$ads_top = htmlentities($ads_top);
$ads_bottom = htmlentities($ads_bottom);
$ads_array = array();
$ads_array[0] = $ads_top;
$ads_array[1] = $ads_right;
$ads_array[2] = $ads_bottom;
$ads_array[3] = $ads_left;
for ((int) $i = 0 ; $i<4 ; $i++) {
$j = $i+1;
$ins_ads_query = "UPDATE ads SET code = '$ads_array[$i]' WHERE id = '{$j}'";
$result_ads = mysqli_query($connect , $ins_ads_query);
}
} else {
header("Location: ../index.php");
}
?>
JS:
var adsTop = document.getElementById('top');
var adsRight = document.getElementById('right');
var adsBottom = document.getElementById('bottom');
var adsLeft = document.getElementById('left');
var adsSubmit = document.getElementById("ads_submit");
function updateAds(e) {
e.preventDefault();
adsSubmit.innerHTML = "Saving <i class=\"fa fa-circle-o-notch fa-spin\" style=\"font-size:24px\"></i>";
var http = new XMLHttpRequest();
var url = 'ajax/update_ads.php';
var params = 'ads_top='+adsTop.value+'&ads_right='+adsRight.value+'&ads_bottom='+adsBottom.value+'&ads_left='+adsLeft.value;
http.open('POST', url, true);
//Send the proper header information along with the request
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.send(params);
http.onreadystatechange = function() {//Call a function when the state changes.
if(http.readyState == 4 && http.status == 200) {
adsSubmit.innerHTML = "Saved <span class=\"glyphicon glyphicon-floppy-saved\"></span>";
}
}
}
adsSubmit.addEventListener('click' , function(e) {
updateAds(e);
});
это очень странно, я действительно не могу знать, что провоцирует этот заголовок 404, я, ребята, могу вам помочь, я был бы очень благодарен.