ajax - How to Trigger $.getJSON().fail()? -


how change ajax request forcing 404 error or in jquery call function .fail() responds can test it?

$.getjson(urlthing, {     maxresults: 5,     pagetoken: token,     key: "something" }) .done(function(data){      crazy stuff }) .fail(function(jqxhr, textstatus, error){console.log("request failed: "+ textstatus+ ', ' + error);}); }; 

just change url string invalid value give 404

$.getjson('urlthing' + 'testurl', {     maxresults: 5,     pagetoken: token,     key: "something" }) .done(function(data){      crazy stuff }) .fail(function(jqxhr, textstatus, error){console.log("request failed: "+ textstatus+ ', ' + error);}); }; 

Comments