I have an ajax request being sent to a PHP script. If that script
captures an error, I'd like it to echo that error and return whatever
it needs to return to trigger the error callback in my ajax call. I
can't seem to find what that is.  Is it a non-200 status code?  Simply
throwing an error (throw new Exception()) just triggers the success
callback with the error text (not unexpectedly, of course).

I'm using the jQuery form plugin and using the .ajaxSubmit() method,
but I suspect the answer would be the same for a core .ajax() call.
My simplified case looks like this:

$(document).ready ( function() {
        $( '#CommercialVendorAddForm' ).submit (
                function() {
                        $(this).block();

                        $(this).ajaxSubmit ({
                                beforeSubmit: function() {
                                        alert ( 'validating' );
                                },
                                success: function ( responseText, responseCode 
) {
                                        alert ( 'success' );
                                        alert ( responseText );
                                },
                                error: function() {
                                        alert ( 'An error has occured. Your 
application could not be
submitted.' );
                                },
                                complete: function() {
                                        $( '#CommercialVendorAddForm' 
).unblock();
                                }
                        });

                        return false;
                }
        );
});

I can't believe that there's not a way to force the error callback to
receive the response if the server page returns an error, but what is
that way?

Thanks.

Rob

Reply via email to