Solution of your problem:
error: function (xhr, ajaxOptions, thrownError) {
if(xhr.status == 404) {
// some error
}
else if(xhr.status == 403) {
// another error
}
else {
// default error
}
}
On 24. Nov, 16:21 h., ricardobeat <[email protected]> wrote:
> The XHR object and the error are passed as arguments to the ajaxError
> callback:
>
> $.ajaxError(function(event, XHRObject, options, errorThrown){
> console.log( XHRObject.responseText, errorThrown );
>
> });
>
> seehttp://docs.jquery.com/Ajax/ajaxError#callback
>
> On Nov 24, 4:09 am, Adwin Wijaya <[email protected]> wrote:
>
>
>
> > how about using ajaxError events ? but I dont know how to capture the
> > response text if 404 / 500 errors occured.
> > can i use that instead of $.ajax ... ?
>
> > thanks !
>
> > On Nov 24, 12:18 pm, "Jeffrey Kretz" <[email protected]> wrote:
>
> > > The best way would be to use the $.ajax call directly (both the post and
> > > the
> > > get function call $.ajax internally).
>
> > > $.ajax({
> > > type:'GET',
> > > url:'somepath.php',
> > > dataType:'json',
> > > success:do_something,
> > > error:do_something_else
>
> > > });
>
> > > function do_something(results) {
> > > ///
>
> > > }
>
> > > function do_something_else() {
> > > ///
>
> > > }
>
> > > JK
>
> > > -----Original Message-----
> > > From: [email protected] [mailto:[email protected]] On
>
> > > Behalf Of Adwin Wijaya
> > > Sent: Sunday, November 23, 2008 8:58 PM
> > > To: jQuery (English)
> > > Subject: [jQuery] how to capture error 500/404 ?
>
> > > Hi,
>
> > > how to capture error that produced by server (err 505 or 404) inside
> > > $.post() and $.get() ?
>
> > > thanks !!!