AJAX (Asynchronous JavaScript and XML) is a web development technique for creating interactive web applications. With AJAX, web applications can send and retrieve data from a server in the background without interfering with the display and behavior of the existing page. This means you can update parts of a web page, without reloading the whole page.
For example, when you use a search box on an eCommerce site and it suggests products as you type, AJAX is likely at work. This functionality makes your website feel faster and more responsive to users.
Note: This document is meant to serve as a helpful guide for advanced troubleshooting; however, the procedures described are beyond the scope of our support policy and we cannot provide direct assistance with implementing them.
If you would like to seek assistance from a qualified WordPress/WooCommerce Developer, we highly recommend Codeable, or a Certified WooExpert.
AJAX requests
↑ Back to topAn AJAX request lets a web page update small parts of its content without needing to reload the entire page. This makes the page quicker and smoother to use.
Examples in a WooCommerce store:
- Product search: When customers type in the search bar, AJAX helps display product suggestions instantly without reloading the page.
- Adding items to cart: When a customer adds an item to their shopping cart, the cart updates immediately without refreshing the page.
These AJAX-driven features enhance the shopping experience by making it fast and responsive.
View AJAX requests
↑ Back to topTo view and understand AJAX requests in a browser, you can use your browser’s Developer Tools. Here’s a simple way to do it:
- Open developer tools: Right-click on the webpage and select “Inspect” or press
Ctrl+Shift+I
(Cmd+Option+I
on Mac). - Go to the Network tab: Click on the “Network” tab in the Developer Tools. This shows all the network activity that happens when the web page loads and while you interact with it.
- Trigger an AJAX request: Perform the action that triggers the AJAX request, such as adding an item to your cart.
- View the request: Look for new entries that appear in the Network tab. Click on one to see details like the request headers, the response from the server, and the data sent or received.
By examining these details, you can understand what data the server is sending and receiving. This will help troubleshoot issues or get a clearer picture of how your site communicates in real time.
Understand AJAX errors
↑ Back to topAJAX requests can sometimes result in errors that prevent the expected interaction on your website. Here are some common AJAX errors, what they typically look like, what they mean, and general tips on how to fix them:
404 not found
↑ Back to top- What it looks like: The server can’t find the requested resource.
- What it means: The URL for the AJAX request is incorrect.
- How to fix it: Check the URL in your AJAX call to make sure it matches an existing endpoint or path on your server.
500 internal server error
↑ Back to top- What it looks like: The server encountered an unexpected condition.
- What it means: There’s a problem on the server side, such as a bug in the script handling the request.
- How to fix it: Review the server-side code for errors or check server logs to find what’s breaking the script.
403 forbidden
↑ Back to top- What it looks like: The server refuses to respond to the request.
- What it means: The server permissions are preventing the AJAX request.
- How to fix it: Ensure the AJAX request has the necessary permissions and is authenticated if needed.
Timeout error
↑ Back to top- What it looks like: There’s no response, and the request times out.
- What it means: The AJAX request took too long to receive a response from the server.
- How to fix it: Optimize the server-side process to respond quicker or extend the timeout period in the AJAX request.
Syntax error
↑ Back to top- What it looks like: The response text cannot be parsed.
- What it means: The format of the server response is incorrect—usually not properly formatted JSON or XML.
- How to fix it: Ensure the server response is in the correct format and content-type that the AJAX request expects.
When facing any AJAX error, using your browser’s Developer Tools to inspect the Network tab can provide insights into the request headers, status codes, and server responses that help identify and fix the problem more efficiently.
Questions and Support
↑ Back to topDo you still have questions and need assistance?
- Get in touch with a Happiness Engineer via our Help Desk. We provide support for extensions developed by and/or sold on WooCommerce.com, and Jetpack/WordPress.com customers.
- If you are not a customer, we recommend finding help on the WooCommerce Support Forum or hiring a WooExpert agency. They are trusted agencies with a proven track record of building highly customized, scalable online stores. Learn more about WooExpert agencies.