NetworkError: Failed to execute ‘send’ on ‘XMLHttpRequest’

Recently we enhanced our security headers and started facing ‘error in processing request’ in ajax calls.

Error text: NetworkError: Failed to execute ‘send’ on ‘XMLHttpRequest’: Failed to load ‘http://masked.url/ajax.php’. (rejected) It seems that the connection to the server has been lost. Please check your network connectivity and server status.

NetworkError: Failed to execute 'send' on 'XMLHttpRequest'
NetworkError: Failed to execute ‘send’ on ‘XMLHttpRequest’

After troubleshooting, we found that there was an issue with the ajax calls that were rejected because we were recently added a set of Feature-Policy in which sync-xhr was set to none as shown below and it was blocking ajax calls in the server.

Here is our initial Feature-Policy in the NGINX configuration file.

add_header Feature-Policy "accelerometer none; ambient-light-sensor none; autoplay none; camera none; encrypted-media none; fullscreen none; geolocation none; gyroscope none; magnetometer none; microphone none; midi none; payment none; speaker none; usb none; notifications none; sync-xhr none; vibrate none; push none; vr none;";

Sync-xhr controls whether the current document is allowed to make synchronous XMLHttpRequest requests.

Removing it fixes the issue. Just edit the config file and reload or restart the web server once.

Published by AtulHost

Creator of AtulHost. An ardent Linux user. Comes from a business management background. Loves to do research on modern business insights and enterprise solutions like career, education, finance, investments ideas, marketing strategies, and productivity skills; technological trends like automation, artificial intelligence, cloud and edge computing, computer hardware and networking, data science, and the internet of things.

Join the discussion

Required fields are asterisked and email address will not be shared.

Ensure a friendly atmosphere to our members and visitors. Encourage the freedom of expression and exchange of information. Comments that are off-topic will be deleted.