Skip to content

Commit

Permalink
Merge pull request #237 from clef/stop-using-json
Browse files Browse the repository at this point in the history
Stop using json for ajax requests
  • Loading branch information
Jesse Pollak committed Mar 9, 2016
2 parents c025167 + 2ea85f3 commit b2ddbf8
Show file tree
Hide file tree
Showing 17 changed files with 66 additions and 83 deletions.
4 changes: 2 additions & 2 deletions assets/dist/js/badge.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
data.enable = 'badge';
$.extend(data, ajaxData);
$prompt.slideUp();
return $.post(ajaxurl, data, (function() {}), "json");
return $.post(ajaxurl, data, (function() {}));
});
return $prompt.find(".no-badge, .dismiss").click(function(e) {
var data;
Expand All @@ -35,7 +35,7 @@
});
data.disable = true;
$.extend(data, ajaxData);
$.post(ajaxurl, data, (function() {}), "json");
$.post(ajaxurl, data, (function() {}));
return $prompt.slideUp();
});
});
Expand Down
2 changes: 1 addition & 1 deletion assets/dist/js/badge.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 13 additions & 5 deletions assets/dist/js/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
function Utils() {}

Utils.getErrorMessage = function(data) {
try {
data = JSON.parse(data);
} catch (_error) {

}
if (data.error) {
return data.error;
} else if (data.data && data.data.error) {
Expand Down Expand Up @@ -117,7 +122,9 @@
action: this.connectClefAction
};
failure = (function(_this) {
return function(msg) {
return function(data) {
var msg;
msg = ClefUtils.getErrorMessage(data);
return _this.showMessage({
message: _.template(clefTranslations.messages.error.connect)({
error: msg
Expand All @@ -132,7 +139,7 @@
return cb(data);
}
} else {
return failure(ClefUtils.getErrorMessage(data));
return failure(data);
}
}).fail(function(res) {
return failure(res.responseText);
Expand Down Expand Up @@ -258,7 +265,6 @@
}
});
ConnectTutorialView = TutorialView.extend({
connectClefAction: "connect_clef_account_oauth_code",
render: function() {
this.addButton();
return this.constructor.__super__.render.call(this);
Expand Down Expand Up @@ -319,7 +325,9 @@
var data, failure;
e.preventDefault();
failure = (function(_this) {
return function(msg) {
return function(data) {
var msg;
msg = ClefUtils.getErrorMessage(data);
return _this.showMessage({
message: _.template(clefTranslations.messages.error.disconnect)({
error: msg
Expand All @@ -344,7 +352,7 @@
type: "updated"
});
} else {
return failure(ClefUtils.getErrorMessage(data));
return failure(data);
}
};
})(this)).fail(function(res) {
Expand Down
2 changes: 1 addition & 1 deletion assets/dist/js/connect.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b2ddbf8

Please sign in to comment.