I’m getting a ‘DataTables warning – Ajax error’
Some of our customers who use the lazy load option in WooCommerce Product Table see an error message in a box, which says ‘DataTables warning: table_id=wcpt_————— – Ajax error. For more information about this error, please see https://datatables.net/tn/7‘ (or similar).
Why am I getting this error?
The error means that an invalid response was returned from the AJAX (i.e. lazy load) request. This is normally caused by an AJAX error or conflict in your theme or another plugin, which interferes with the output of the AJAX request.
A valid lazy load request and response looks like this:
Page loads -> product table loads without any data (i.e. just the headings) -> AJAX request fired -> products load -> product data returned to browser in JSON format -> JSON data added to table -> Spinner icon disappears.
An invalid request and response looks like this:
Page loads -> product table loads without any data (i.e. just the headings) -> AJAX request fired -> products load, but an error is triggered or something interferes with JSON output -> DataTables doesn’t find a valid response and displays an error message.
How to fix the DataTables Ajax error
The simplest way to fix this error is to disable lazy load.
If you need to use lazy load because of the number of products in your table, then you can troubleshoot the error as follows:
- Temporarily switch to a default theme (e.g. TwentySeventeen) and disable all the plugins apart from WooCommerce and WooCommerce Product Table.
- Try to load the table again, and see if it fixes the error.
- If it fixes the error, reactivate everything one by one to find the cause of the problem. If it doesn’t fix the error, please send us a support request with your WordPress login details and a link to the page with the product table.
DataTables (the jQuery plugin used by WooCommerce Product Tables) has provided this documentation on how to further troubleshoot the error. This involves looking in the Developer tools to inspect the AJAX response.