user1016265
user1016265

Reputation: 2387

global ajaxError handler jquery

on Jquery websites says that i should attach ajaxError method to some html elemnt.

It means i have to have such element. But i wont use it.

I want to have one global handler which will handle all ajax error messages.

I've tried like here jquery Ajax $.ajaxError

but i'm getting error message

http://o7.no/xnbFsj

and line 16 is

http://o7.no/xlLVPI

Upvotes: 1

Views: 1563

Answers (2)

Aleja_Vigo
Aleja_Vigo

Reputation: 980

You have to attach the handler to any element. And to make it global:

$(document).ajaxError(function(){...

http://api.jquery.com/ajaxError/

Upvotes: 3

Darin Dimitrov
Darin Dimitrov

Reputation: 1038710

How about attaching it to the document:

$(document).ajaxError(function(event, jqXHR, ajaxSettings, thrownError) {
    ...
});

Upvotes: 1

Related Questions