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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -