Mercurial > kallithea
changeset 4704:265032dfbd76
javascripts: jQuery version of ajaxPOST
author | Takumi IINO <trot.thunder@gmail.com> |
---|---|
date | Sat, 29 Nov 2014 16:04:25 +0900 |
parents | a14e9bff164b |
children | 4a57462b5101 |
files | kallithea/public/js/base.js kallithea/templates/changeset/changeset_file_comment.html |
diffstat | 2 files changed, 13 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/public/js/base.js Mon Dec 15 13:47:36 2014 +0100 +++ b/kallithea/public/js/base.js Sat Nov 29 16:04:25 2014 +0900 @@ -400,19 +400,15 @@ }; var ajaxPOST = function(url,postData,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) { - alert("Ajax POST error: " + o.statusText); - } - }; var postData = _toQueryString(postData); - var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData); - return request; + return $.ajax({url: url, data: postData, type: 'POST', headers: {'X-PARTIAL-XHR': '1'}, cache: false}) + .done(success) + .fail(function(jqXHR, textStatus, errorThrown) { + if (textStatus == "abort") + return; + alert("Ajax POST error: " + textStatus); + }) + ; }; @@ -690,10 +686,9 @@ $overlay.show(); - var success = function(o){ + var success = function(json_data){ $tr.removeClass('form-open'); $form.remove(); - var json_data = JSON.parse(o.responseText); _renderInlineComment(json_data); }; var postData = { @@ -718,8 +713,8 @@ var url = pyroutes.url('changeset_comment_preview', {'repo_name': REPO_NAME}); var post_data = {'text': text}; - ajaxPOST(url, post_data, function(o){ - $('#preview-box_'+lineno).html(o.responseText); + ajaxPOST(url, post_data, function(html){ + $('#preview-box_'+lineno).html(html); $('#preview-box_'+lineno).removeClass('unloaded'); }) })
--- a/kallithea/templates/changeset/changeset_file_comment.html Mon Dec 15 13:47:36 2014 +0100 +++ b/kallithea/templates/changeset/changeset_file_comment.html Sat Nov 29 16:04:25 2014 +0900 @@ -213,8 +213,8 @@ $('#preview-btn').hide(); var url = pyroutes.url('changeset_comment_preview', {'repo_name': '${c.repo_name}'}); - ajaxPOST(url,post_data,function(o){ - $('#preview-box').html(o.responseText); + ajaxPOST(url,post_data,function(html){ + $('#preview-box').html(html); $('#preview-box').removeClass('unloaded'); }); });