Ajax error trap basic problems

Ajax error trap basic problems

I am trying to catch a few basics errors that at some point I expect to happen in an application under development. For example two basic cases spring to mind:
  1. Server down
  2. Some sort of malformed call to the server code that results in a non standard server response (e.g., PHP error message is returned).
My current design is that the server code always responds with html MIME type.  Typically it issues JSON data back to the client.
 
What I don't get is that if I turn off the web server and then run it the success callback in invoked.  Sorry, but this makes no sense.  How do I detect the web server being down?

Secondly, when I set up the application so the Ajax request causes a PHP error (i.e., server responds with a 200 but it's just a jumble of HTML about a PHP undefined class::method call) I again land in the success callback.  This makes sense via the jQuery API docs as the server did respond.  However, if I try to parse the response with jQuery.parseJSON() I end up with an unusable null object. jQuery.parseJSON does not throw and error which the docs lead me to believe it will.  Any ideas on how to handle?

Also, what about handling a 404 or other oddball server response?

    $.ajax({
        type:"POST",
        url:url_resources.controller,
        data:({ctl : ctlString, data : dataString}),
        beforeSend:function() {
                       if (progress == 'general') {
                           $('#general_progress_indicator').show();
                       }
                   },
        error: function(XMLHttpRequest, textStatus, errorThrown){
            alert('XHR: ' + XMLHttpRequest + "\n" + 'textStatus: ' + textStatus + "\n" + 'errorThrown: ' + errorThrown);
        },
        success:function(data) {
        alert('in success');
                   if (progress == 'general') {
                       $('#general_progress_indicator').hide();
                   }

                   alert('data:' + data);
                   var retData = jQuery.parseJSON(data);
alert(retData.status);
                   if (retData.status === null) {
                       alert('Something really crazy happened!');
                   }
                   if (retData.status != 'success') {
                       alert('Something crazy happened!');
                   }
                   else if (retData.status == 'failed') {
                       alert('AJAX ERROR: ' + retData.error);
                   }
                   else if (retData.status == 'success') {
                       alert('success');
                       if (post_action == 'move_bs') {
                           re_position_bs(obj, post_arg, true);
                       }
                       else if (post_action == 'reload') {
                           location.reload(true);
                       }
                   }
                }
    })