I'm trying to get my error function called when an external json fails to load.
This works fine with .getJSON, but doesn't with .ajax. Can anyone take a look at the code and tell me if I missed something?
JSfiddle here: http://jsfiddle.net/8C7Hb/
$.getJSON( "http://foo.com/bar.json", function() {
$('#method1_result').html('Success');
}).fail(function() { $('#method1_result').html('Fail'); });
$.ajax({
url: "http://foo.com/bar.json",
dataType: "jsonp",
success: function(data) {
$('#method2_result').html('Success');
},
error: function() {
$('#method2_result').html('Error');
}
}).fail(function() { $('#method2_result').html('Fail'); });
Thank you.