You can add the fail mathod for executing you error block codes.
function loadRepos() {
$.ajax({
url: "https://api.github.com/legacy/repos/search/javascript",
timeout: 1000, //change it to any value you want in milliseconds
})
.done(function(data) {
var i, repo;
$.each(data.repositories, function (i, repo) {
$("#allRepos").append("<li><a href='https://github.com/" + repo.username + "/" + repo.name + "'>"
+ "<h4>" + repo.name + "</h4>"
+ "<p>" + repo.username + "</p></a></li>");
});
$('#allRepos').listview('refresh');
setTimeout(function(){
loadRepos();
}, 300000);
})
.fail(function (xhr, textStatus, thrownError) {
alert(xhr.statusText);
alert(xhr.responseText);
alert(xhr.status);
alert(thrownError);
});
}