Throwing an AJAX error that jQuery can catch
<p>Using <code>jquery.ajax()</code> there are events such as "success" and "error" get triggered.</p>

<p>It appears as though the "error" is only triggered if some error occurs within the JavaScript function that is calling <code>ajax()</code>, rather than being based on some error coming back from the HTTP call.</p>

<p>I would like to do one action on success and another if some error happens within my server side processing.</p>

<p>What is the/is there an accepted practice of passing back a success or failure such that your client-side JS can display an error or success message?</p>

<p>@jason - so your code looks something like this....</p>

<pre><code>$.ajax({   
    type: "POST",
    dataType: "html", 
    cache: false,  
    url: "ajax_post_action.php",
    success: function(data){            
        if( response.success ) { 
            ...do something... 
        } else {
            ...tell user thre was a problem...
        }          
    },
    error: function(data){                  
        ...tell user thre was a problem...
    }   
    });
</code></pre>
