im trying to get some data from the Fetch.php but unfortunately there's an error.
I tried to use an older version of jQuery but it's not working either. Now I'm using jQuery 3.5.1
The ajax script:
<script>
$(document).ready(function() {
load_data();
function load_data(query)
{
$.ajax({
type: 'POST',
url: 'Fetch.php',
data: {query: query},
success: function(data)
{
$('#result').html(data);
},
error: function (err) {
console.log(err);
}
});
}
$('#search_text').keyup(function() {
const search = $('#search_text').val();
if(search != '')
{
load_data(search);
}
else
{
load_data();
}
});
});
Fetch.php
var_dump('query: ' . $_POST["query"]);
Error:
jquery.min.js:4 POST Fetch.php 500
send @ jquery.min.js:4
ajax @ jquery.min.js:4
load_data @ index.php:46
(anonymous) @ index.php:65
dispatch @ jquery.min.js:3
r.handle @ jquery.min.js:3