diff --git a/kallithea/public/js/base.js b/kallithea/public/js/base.js --- a/kallithea/public/js/base.js +++ b/kallithea/public/js/base.js @@ -362,7 +362,7 @@ function asynchtml(url, $target, success } $target.html(_TM['Loading ...']).css('opacity','0.3'); - $.ajax({url: url, data: args, headers: {'X-PARTIAL-XHR': '1'}, cache: false, dataType: 'html'}) + return $.ajax({url: url, data: args, headers: {'X-PARTIAL-XHR': '1'}, cache: false, dataType: 'html'}) .done(function(html) { $target.html(html); $target.css('opacity','1.0'); @@ -372,6 +372,8 @@ function asynchtml(url, $target, success } }) .fail(function(jqXHR, textStatus, errorThrown) { + if (textStatus == "abort") + return; console.log('Ajax failure: ' + textStatus); $target.html('ERROR: {0}'.format(textStatus)); $target.css('opacity','1.0'); diff --git a/kallithea/templates/pullrequests/pullrequest.html b/kallithea/templates/pullrequests/pullrequest.html --- a/kallithea/templates/pullrequests/pullrequest.html +++ b/kallithea/templates/pullrequests/pullrequest.html @@ -146,10 +146,16 @@ pyroutes.register('pullrequest_repo_info', "${url('pullrequest_repo_info',repo_name='%(repo_name)s')}", ['repo_name']); + var pendingajax = undefined; var otherrepoChanged = function(){ var repo_name = $('#other_repo').val(); - ajaxGET(pyroutes.url('pullrequest_repo_info', {"repo_name": repo_name}), + if (pendingajax) { + pendingajax.abort(); + pendingajax = undefined; + } + pendingajax = ajaxGET(pyroutes.url('pullrequest_repo_info', {"repo_name": repo_name}), function(o){ + pendingajax = undefined; var data = JSON.parse(o.responseText); $('#other_repo_desc').html(data.description); @@ -217,7 +223,12 @@ url = url.replace(k,rev_data[k]); } - asynchtml(url, $('#pull_request_overview'), function(o){ + if (pendingajax) { + pendingajax.abort(); + pendingajax = undefined; + } + pendingajax = asynchtml(url, $('#pull_request_overview'), function(o){ + pendingajax = undefined; var jsdata = eval('('+YUD.get('jsdata').innerHTML+')'); // TODO: just get json var r = new BranchRenderer('graph_canvas', 'graph_content_pr'); r.render(jsdata,100);