Using AJAX and handling server errors

In an ideal world, your web application would never go wrong. Unfortunately, this is not the case, and web developers need to gracefully handle errors and provide the user with useful feedback.

For example, system errors occur when a server cannot be reached or a file/web page is missing. System errors are typically unavoidable and out of the user's control. They differ from application errors such as invalid data input, which a user can correct.

Getting ready

Since this recipe deals with AJAX errors and we will be calling a PHP script that does not exist, we only require HTML and JavaScript for this recipe. Create a blank HTML document named recipe-2.html and ensure that you have the latest version of jQuery ...

Get jQuery 2.0 Development Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.