Reputation: 632
I have a live AJAX search bar that bring records from a MySQL database. However when you repeatedly search for records by changing the searchbar the web browsers throws the error 'ERR_EMPTY_RESPONSE'.
ERR_EMPTY_RESPONSE
If you try to refresh the page it crashes for 60 (Approx.) seconds. https://i.sstatic.net/ySAwT.jpg
I'm using a GoDaddy server if it makes any differences.
I have tried increasing the PHP memory limit to 512mb as suggested in other questions. This appeared to make no difference.
This is my Javascript
<script type="text/javascript">
$(document).ready(function()
{
$(".product_check").click(function()
{
$("#loader").show();
var action = 'data';
var eventname = get_filter_text('eventname');
var category = get_filter_text('category');
var year = get_filter_text('year');
var num = document.getElementById('num').value;
$.ajax(
{
url:'action.php',
method:'POST',
data:{action:action, eventname:eventname, category:category, year:year, num:num}, success:function(response)
{
$("#result").html(response);
$("#loader").hide();
$("#textChange").text("Filtered Products");
}
});
});
$(".tb").keyup(function()
{
$("#loader").show();
var action = 'data';
var eventname = get_filter_text('eventname');
var category = get_filter_text('category');
var year = get_filter_text('year');
var num = document.getElementById('num').value;
$.ajax(
{
url:'action.php',
method:'POST',
data:{action:action, eventname:eventname, category:category, year:year, num:num}, success:function(response)
{
$("#result").html(response);
$("#loader").hide();
$("#textChange").text("Filtered Products");
}
});
});
function get_filter_text(text_id)
{
var filterData = [];
$('#'+text_id+':checked').each(function()
{
filterData.push($(this).val());
});
return filterData;
}
});
</script>
this is my backend PHP
if(isset($_POST['action']))
{
$sql = "SELECT * FROM tb_ETSlips WHERE eventname != ''";
if(isset($_POST['eventname']))
{
$eventname = implode("','", $_POST['eventname']);
$sql .= "AND eventname IN('" . $eventname . "')";
}
if(isset($_POST['year']))
{
$year = implode("','", $_POST['year']);
$sql .= "AND year(timestamp) IN('" . $year . "')";
}
if(isset($_POST['category']))
{
$category = implode("','", $_POST['category']);
$sql .= "AND category IN('" . $category . "')";
}
if(isset($_POST['num']))
{
$num = $_POST['num'];
$sql .= "AND (number LIKE '%" . $num . "%' ";
$sql .= "OR name LIKE '%" . $num . "%')";
}
$result = $conn->query($sql);
$output='';
if($result->num_rows>0)
{
while ($row=$result->fetch_assoc())
{
$output .='<tr>
<td>' . $row['timestamp'] . '</td>
<td>' . $row['number'] . '</td>
<td>' . $row['dname'] . '</td>
<td>' . $row['reaction'] . '</td>
<td>' . $row['et1320'] . '</td>
<td>' . $row['sp1320'] . '</td>
<td>' . $row['lane'] . '</td>
</tr>';
}
}
else
{
$output = "<h3>No times found!</h3>";
}
echo $output;
}
?>
Upvotes: 1
Views: 182
Reputation: 632
"I was having the same issue, 40 POST requests/minute would cause my site to lock up for 1 minute. Found the similar issue here (stackoverflow) with the solution.
SOLUTION:
GoDaddy limts the amount of POST request that can be made, regardless if they say they don't. In my case I needed to use the correct method for the job being used. In my case, I was using POST to go to a PHP site that would then GET information and return it. I changed my POST request to a GET request and the issue went away.
Only use POST when absolutely necessary, GoDaddy will limit."
Upvotes: 2