lipsumar
lipsumar

Reputation: 981

ajaxError does not trigger but error does

There must be something I don't get here. I request a url that respond with a 404, so the following code works:

$.ajax({
    url: '/echo/error',
    success: function(){
        alert('that was a success');   
    },
    error: function(){
        alert('error');   
    },
    complete: function(){
        alert('complete');
    }
});

It will alert "error" then "complete". That's fine.

The problem is that if i add this before:

$('document').ajaxError(function(){
    alert('ajaxError');
});

$('document').ajaxComplete(function(){
    alert('ajaxComplete');
});

I never get "ajaxError" or "ajaxComplete". What am I doing wrong ? (I'm using jQuery 1.9.1)

Here is the fiddle: http://jsfiddle.net/CQmZ8/

Upvotes: 0

Views: 434

Answers (1)

lipsumar
lipsumar

Reputation: 981

Use $(document) instead of $('document').

Thank you A. Wolff for the quick answer.

Upvotes: 1

Related Questions