I want to handle 404 error if script can't load some resouce after document is ready.
Here is code:
(function( $ ){
$.fn.onair=function(){
var tid = setInterval( function () {
if ( document.readyState !== 'complete' ){
return;
alert("salam")
}
else if(document.readyState=='complete'){
if (document.onerror){
//ajax
$.ajax({
statusCode: {
404: function() {
alert("page not found");
}
}
});
//ajax
alert("s");
clearInterval( tid );
}
}
}, 10 );
}
})( jQuery )