changeset 4705:4a57462b5101

javascripts: jQuery version of ajaxGET
author Takumi IINO <trot.thunder@gmail.com>
date Sat, 29 Nov 2014 16:04:42 +0900
parents 265032dfbd76
children 94a7abdac8f6
files kallithea/public/js/base.js kallithea/templates/pullrequests/pullrequest.html
diffstat 2 files changed, 10 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/public/js/base.js	Sat Nov 29 16:04:25 2014 +0900
+++ b/kallithea/public/js/base.js	Sat Nov 29 16:04:42 2014 +0900
@@ -382,21 +382,14 @@
 };
 
 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 @@
         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);
--- a/kallithea/templates/pullrequests/pullrequest.html	Sat Nov 29 16:04:25 2014 +0900
+++ b/kallithea/templates/pullrequests/pullrequest.html	Sat Nov 29 16:04:42 2014 +0900
@@ -156,9 +156,8 @@
           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