Why does $.getJSON silently fail?
问题 It seems very inconvenient that jQuery's $.getJSON silently fails when the data returned is not valid JSON. Why was this implemented with silent failure? What is the easiest way to perform getJSON with better failure behavior (e.g. throw an exception, console.log() , or whatever)? 回答1: you can use function name() { $.getJSON("", function(d) { alert("success"); }).done(function(d) { alert("done"); }).fail(function(d) { alert("error"); }).always(function(d) { alert("complete"); }); } If you