summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/services/ajax_service.js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web/static/src/js/services/ajax_service.js')
-rw-r--r--addons/web/static/src/js/services/ajax_service.js25
1 files changed, 13 insertions, 12 deletions
diff --git a/addons/web/static/src/js/services/ajax_service.js b/addons/web/static/src/js/services/ajax_service.js
index 0cecaae9da3..cb83dd9d553 100644
--- a/addons/web/static/src/js/services/ajax_service.js
+++ b/addons/web/static/src/js/services/ajax_service.js
@@ -7,19 +7,20 @@ var session = require('web.session');
var AjaxService = AbstractService.extend({
rpc: function (route, args, options, target) {
- var def = $.Deferred();
- var promise = def.promise();
- var xhrDef = session.rpc(route, args, options);
- promise.abort = xhrDef.abort.bind(xhrDef);
- xhrDef.then(function () {
- if (!target.isDestroyed()) {
- def.resolve.apply(def, arguments);
- }
- }).fail(function () {
- if (!target.isDestroyed()) {
- def.reject.apply(def, arguments);
- }
+ var rpcPromise;
+ var promise = new Promise(function (resolve, reject) {
+ rpcPromise = session.rpc(route, args, options);
+ rpcPromise.then(function (result) {
+ if (!target.isDestroyed()) {
+ resolve(result);
+ }
+ }).guardedCatch(function (reason) {
+ if (!target.isDestroyed()) {
+ reject(reason);
+ }
+ });
});
+ promise.abort = rpcPromise.abort.bind(rpcPromise);
return promise;
},
});