Skip to content

Commit

Permalink
Fix regression with .always method in ajax
Browse files Browse the repository at this point in the history
  • Loading branch information
artf committed Jun 30, 2017
1 parent 63e0fd0 commit 4140a06
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/storage_manager/model/RemoteStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,18 @@ module.exports = Backbone.Model.extend({
for(var key in params)
fd[key] = params[key];

$.ajax({
let req = $.ajax({
url: this.get('urlStore'),
beforeSend: this.get('beforeSend'),
complete: this.get('onComplete'),
method: 'POST',
dataType: 'json',
contentType: this.get('contentTypeJson') ? 'application/json; charset=utf-8': 'x-www-form-urlencoded',
data: this.get('contentTypeJson') ? JSON.stringify(fd): fd,
}).always(() => {
});

// Assign always callback when possible
req && req.always && req.always(() => {
if (typeof clb == 'function') {
clb();
}
Expand All @@ -52,7 +55,7 @@ module.exports = Backbone.Model.extend({

fd.keys = keys;

$.ajax({
let req = $.ajax({
url: this.get('urlLoad'),
beforeSend: this.get('beforeSend'),
complete: this.get('onComplete'),
Expand All @@ -61,7 +64,10 @@ module.exports = Backbone.Model.extend({
method: 'GET',
}).done(d => {
result = d;
}).always((res) => {
});

// Assign always callback when possible
req && req.always && req.always((res) => {
if (typeof clb == 'function') {
clb(res);
}
Expand Down

0 comments on commit 4140a06

Please sign in to comment.