I have a strange issue on a website for a customer. He is hosting via GoDaddy.
Some context: It is a custom WordPress site fetching content via Ajax to load into the page.
Problem statement: When testing, I noticed some random occurrences for empty responses coming back from the server. Triggering the same request over and over, it happens that the response header is empty. This is strange as I had performed the same test seconds / minutes before.
This is the result of a successful response:
"finishTitle":"Bourland 2","finishNumber":"VP2","highlightImage":"https:\/\/qdr.app\/wp-content\/uploads\/2024\/08\/leathershandtas6-320x202-1.jpg","galleryImages":"<img src=\"https:\/\/qdr.app\/wp-content\/uploads\/2024\/08\/leathershandtas6-320x202-1-150x150.jpg\" class=\"selectedFinishImage\" data-large-src=\"https:\/\/qdr.app\/wp-content\/uploads\/2024\/08\/leathershandtas6-320x202-1.jpg\" alt=\"\" \/><img src=\"https:\/\/qdr.app\/wp-content\/uploads\/2024\/08\/leathershandtas3-320x202-1-150x150.jpg\" data-large-src=\"https:\/\/qdr.app\/wp-content\/uploads\/2024\/08\/leathershandtas3-320x202-1.jpg\" alt=\"\" \/><img src=\"https:\/\/qdr.app\/wp-content\/uploads\/2024\/06\/8CCL-Basement-Office-Doors-Looking-at-Egress-150x150.jpg\" data-large-src=\"https:\/\/qdr.app\/wp-content\/uploads\/2024\/06\/8CCL-Basement-Office-Doors-Looking-at-Egress-1024x681.jpg\" alt=\"\" \/><img src=\"https:\/\/qdr.app\/wp-content\/uploads\/2024\/08\/leathershandtas5-320x202-1-150x150.jpg\" data-large-src=\"https:\/\/qdr.app\/wp-content\/uploads\/2024\/08\/leathershandtas5-320x202-1.jpg\" alt=\"\" \/>"
With a response header looking like this:
Result from an empty response:
The response itself is empty.
We have the following response headers. You can see the difference.
What could cause this and how can it be solved?
My JavaScript
$(document).on('click', '.all-finishes-list li', function()
var finishId = $(this).data('finish-id');
var $li = $(this);
// Make an AJAX request to get the details for the clicked finish
$.ajax(
url: load_more_params.ajaxurl,
type: 'POST',
data:
action: 'fetch_finish_details',
finish_id: finishId
,
success: function(response)
if(!response)
alert('empty') ;
else
var data = JSON.parse(response);
// Update the highlighted image
// DO STUFF WITH IT
,
error: function()
alert('Error updating finish details. Please try again.');
);
);
The related PHP code.
function fetch_finish_details()
add_action('wp_ajax_fetch_finish_details', 'fetch_finish_details');
add_action('wp_ajax_nopriv_fetch_finish_details', 'fetch_finish_details');function