# HG changeset patch # User Takumi IINO # Date 2014-11-29 08:04:42 # Node ID 4a57462b5101db8c4084c27d9fc1b1bebfe7b9c6 # Parent 265032dfbd76ccd6f8a4e08f2e581859a0eee2a4 javascripts: jQuery version of ajaxGET 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 @@ -382,21 +382,14 @@ function asynchtml(url, $target, success }; var ajaxGET = function(url,success) { - // Set special header for ajax == HTTP_X_PARTIAL_XHR - YUC.initHeader('X-PARTIAL-XHR',true); - - var sUrl = url; - var callback = { - success: success, - failure: function (o) { - if (o.status != 0) { - alert("Ajax GET error: " + o.statusText); - }; - } - }; - - var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback); - return request; + return $.ajax({url: url, headers: {'X-PARTIAL-XHR': '1'}, cache: false}) + .done(success) + .fail(function(jqXHR, textStatus, errorThrown) { + if (textStatus == "abort") + return; + alert("Ajax GET error: " + textStatus); + }) + ; }; var ajaxPOST = function(url,postData,success) { @@ -436,8 +429,7 @@ var show_changeset_tooltip = function(){ if(rid && !$target.hasClass('tooltip')){ _show_tooltip(e, _TM['loading ...']); var url = pyroutes.url('changeset_info', {"repo_name": repo_name, "revision": rid}); - ajaxGET(url, function(o){ - var json = JSON.parse(o.responseText); + ajaxGET(url, function(json){ $target.addClass('tooltip') _show_tooltip(e, json['message']); _activate_tooltip($target); 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 @@ -156,9 +156,8 @@ ${self.repo_context_bar('showpullrequest pendingajax = undefined; } pendingajax = ajaxGET(pyroutes.url('pullrequest_repo_info', {"repo_name": repo_name}), - function(o){ + function(data){ pendingajax = undefined; - var data = JSON.parse(o.responseText); $('#other_repo_desc').html(data.description); // replace options of other_ref with the ones for the current other_repo