Trip
Trip

Reputation: 27114

Using jQuery 1.4.4 This simple method fails for some reason

$.get($(this).attr('rel'), function(response){}, 'script')
.error(function(){ alert('this failed')});

I get. .error is not a method . But it was added in version 1.4.3

http://api.jquery.com/error/

Is there some kind of type I have ?

Upvotes: 3

Views: 157

Answers (1)

Explosion Pills
Explosion Pills

Reputation: 191729

The return value of $.get in jQuery 1.4.3 does not have a .error method. I am actually not sure what the return value is, but you should be able to check it .. whatever it is, it doesn't have .error. You will have to bind it to something else.

At some point, jQuery started returning jqxhr objects from $.get, $.post, $.ajax, etc. I believe this is after 1.5 when they introduced Deferred, but I'm not 100% sure. The jqxhr object has .done, .fail and .always (implementing Deferred), so you would be able to do $.get().fail() at some point after jQuery 1.5. You definitely can in jQuery 1.7.

Either upgrade jQuery or use $.ajax instead with error as a setting.

Upvotes: 4

Related Questions