full erorr
Access to XMLHttpRequest at 'https:/domain/errors/403/' (redirected from 'http://domain/includes/action.php') from origin 'domain' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header has a value 'http://domain' that is not equal to the supplied origin.
the code should to search without refresh so in localhost all work right but when i go to server i got this erorr in console
here is my php where i got a response to my main page
<?php
include 'db.php';
if (isset($_POST['search'])) {
$Name = $_POST['search'];
$Query = "SELECT * FROM items WHERE name LIKE '%$Name%' OR namea LIKE '%$Name%' LIMIT 6";
$q2 = "SELECT * FROM items WHERE namea LIKE '%$Name%' LIMIT 6";
$ExecQuery = mysqli_query($con, $Query);
$ExecQuery2 = mysqli_query($con, $q2);
if ($ExecQuery) {
$go = $ExecQuery;
} else {
$go = $ExecQuery2;
}
echo '<ul class="cards">';
while ($row = mysqli_fetch_array($go)) {
$name = $row['name'];
$p = $row['price'];
$d = $row['descrip'];
$m = $row['img'];
echo '
<li class="cards__item">
<div class="card">
<img src="pimg/' . $m . '" class="card__image">
<div class="card__content">
<div class="card__title">name: ' . $name . '</div>
<div class="card__title">price: ' . $p . ' $</div>
<p class="card__text">' . $d . '</p>
</div>
</div>
</li>';
}
}
here is my js code to send the data to search.php and got the response
function fill(Value) {
$('#search').val(Value);
$('#display').hide();
}
$(document).ready(function () {
$("#search").keyup(function () {
var name = $('#search').val();
if (name != "") {
$.ajax({
type: "POST",
url: "includes/search.php",
data: {
search: name
},
success: function (html) {
$("#display").html(html).show();
}
});
}
});
});