Magento Onepage Checkout & Ajax
The Magento Onepage checkout is split into sections: login; billing address; shipping address; shipping method; payment details and order review. As the user progresses through each section, an Ajax request is sent to Magento with the information relating to the current section. For example, when a user hits the continue button on the billing section, an Ajax request is sent to Magento with the user's billing address.This triggers a Magento controller that saves the data into the user's sales quote. This is useful because if the user decides to go back through your site and add something else to their cart (which is always good), they won't have to re-add their billing address. If you use a network traffic monitor - I use the Firefox plugin Httpfox - you can see these requests being sent and the data returned. Give it a try for yourself as it should help illustrate how the Magento Onepage checkout works.
Notice the first alert, the one you just added. This alerts out transport.responseText, the content sent back from the Ajax response. Not only will this include JSON produced that Magento expects, the error message will have also been inserted, meaning that the response cannot be parsed as JSON data.
My error was related to a reward points module that I had installed for a client. I temporarily disabled the module and was able to checkout with no problems what so ever.
The undefined error is usually caused by a simple Magento template or model error. The fact that the error is triggered during an Ajax request makes it difficult to track down and debug. Fortunately, following the above steps should allow you to see the error message in a few minutes. Magento could easily overcome this problem by logging all malformed Ajax responses in the checkout and forwarding them on to a specified email address.
A Few Tips
- If you manage to find your error but have trouble fixing it, by all means post it in the comments or email me and I will do my best to help you solve the problem!