From 2f961ee830af21166d22bf3fae104291f614e7dd Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 30 Nov 2018 15:23:48 +0300 Subject: plugins: add some xhrPost refactoring --- plugins/mail/mail.js | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'plugins/mail/mail.js') diff --git a/plugins/mail/mail.js b/plugins/mail/mail.js index db0503ff9..929b35243 100644 --- a/plugins/mail/mail.js +++ b/plugins/mail/mail.js @@ -22,15 +22,9 @@ function emailArticle(id) { style: "width: 600px", execute: function() { if (this.validate()) { - - new Ajax.Request("backend.php", { - parameters: dojo.objectToQuery(this.attr('value')), - onComplete: function(transport) { - console.log(transport.responseText); - - var reply = JSON.parse(transport.responseText); - - var error = reply['error']; + xhrJson("backend.php", this.attr('value'), (reply) => { + if (reply) { + const error = reply['error']; if (error) { alert(__('Error sending email:') + ' ' + error); @@ -39,7 +33,8 @@ function emailArticle(id) { dialog.hide(); } - } }); + } + }); } }, href: query}); -- cgit v1.2.3