The key word that you are missing is a โstatus codeโ (what we collectively call all HTTP response codes 200, 404, 500, etc.). I assume you are using jQuery, in which case all the documentation necessary for AJAX to work is at http://api.jquery.com/jQuery.ajax/
Here is a simple request example that displays a warning, but only if the 404 status code is returned (almost literally lifted the link above):
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script> $(function() { var url = "some_url"; $.ajax(url, { statusCode: { 404: function() { alert('page not found'); } } }); }); </script>
source share