Updated Ajax.js to avoid promise workaround
- Removed get method in ajax.js as it's useless
This commit is contained in:
@@ -10,9 +10,6 @@ define('ajax', ['mailpoet', 'jquery', 'underscore'], function(MailPoet, jQuery,
|
|||||||
token: null,
|
token: null,
|
||||||
data: {}
|
data: {}
|
||||||
},
|
},
|
||||||
get: function(options) {
|
|
||||||
return this.request('get', options);
|
|
||||||
},
|
|
||||||
post: function(options) {
|
post: function(options) {
|
||||||
return this.request('post', options);
|
return this.request('post', options);
|
||||||
},
|
},
|
||||||
@@ -54,26 +51,17 @@ define('ajax', ['mailpoet', 'jquery', 'underscore'], function(MailPoet, jQuery,
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// make ajax request depending on method
|
// ajax request
|
||||||
if(method === 'get') {
|
deferred = jQuery.post(
|
||||||
jQuery.get(
|
this.options.url,
|
||||||
this.options.url,
|
params,
|
||||||
params,
|
null,
|
||||||
null,
|
'json'
|
||||||
'json'
|
).then(function(data) {
|
||||||
);
|
return data;
|
||||||
} else {
|
}, function(xhr) {
|
||||||
jQuery.post(
|
return xhr.responseJSON;
|
||||||
this.options.url,
|
});
|
||||||
params,
|
|
||||||
null,
|
|
||||||
'json'
|
|
||||||
).then(function(data) {
|
|
||||||
deferred.resolve(data);
|
|
||||||
}, function(xhr) {
|
|
||||||
deferred.reject(xhr.responseJSON);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// clear options
|
// clear options
|
||||||
this.options = {};
|
this.options = {};
|
||||||
|
Reference in New Issue
Block a user