Merge pull request #238 from mailpoet/queue

Queue
This commit is contained in:
Marco
2015-11-20 23:02:30 +01:00
10 changed files with 305 additions and 6 deletions

View File

@@ -10,7 +10,8 @@ define('ajax', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
token: null,
data: {},
onSuccess: function(data, textStatus, xhr) {},
onError: function(xhr, textStatus, errorThrown) {}
onError: function(xhr, textStatus, errorThrown) {},
onComplete: function(xhr) {}
},
get: function(options) {
return this.request('get', options);
@@ -18,6 +19,9 @@ define('ajax', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
post: function(options) {
return this.request('post', options);
},
head: function(options) {
return this.request('head', options);
},
delete: function(options) {
return this.request('delete', options);
},
@@ -60,14 +64,23 @@ define('ajax', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
this.options.onSuccess,
'json'
);
} else {
}
else if (method === 'head') {
jqXHR = jQuery.ajax({
url: this.options.url,
type : 'head',
complete : this.options.onComplete
});
}
else {
jqXHR = jQuery.ajax({
url: this.options.url,
type : 'post',
data: params,
dataType: 'json',
success : this.options.onSuccess,
error : this.options.onError
error : this.options.onError,
complete : this.options.onComplete
});
}