Updated Ajax.js to avoid promise workaround

- Removed get method in ajax.js as it's useless
This commit is contained in:
Jonathan Labreuille
2016-08-02 18:08:12 +02:00
parent b05344b1d3
commit afa0d3af63

View File

@@ -10,9 +10,6 @@ define('ajax', ['mailpoet', 'jquery', 'underscore'], function(MailPoet, jQuery,
token: null,
data: {}
},
get: function(options) {
return this.request('get', options);
},
post: function(options) {
return this.request('post', options);
},
@@ -54,26 +51,17 @@ define('ajax', ['mailpoet', 'jquery', 'underscore'], function(MailPoet, jQuery,
})
}
// make ajax request depending on method
if(method === 'get') {
jQuery.get(
this.options.url,
params,
null,
'json'
);
} else {
jQuery.post(
this.options.url,
params,
null,
'json'
).then(function(data) {
deferred.resolve(data);
}, function(xhr) {
deferred.reject(xhr.responseJSON);
});
}
// ajax request
deferred = jQuery.post(
this.options.url,
params,
null,
'json'
).then(function(data) {
return data;
}, function(xhr) {
return xhr.responseJSON;
});
// clear options
this.options = {};