Fix $.ajax handling of errors