Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Item13096: incorrect handling of unauthorised response
  • Loading branch information
Comment committed Dec 2, 2014
1 parent f2eb8e3 commit 7bca1b4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CommentPlugin/lib/Foswiki/Plugins/CommentPlugin.pm
Expand Up @@ -238,7 +238,7 @@ sub _restSave {
my $e = shift;
if ($isXHR) {
$response->header( -status => 404 );
$response->body(shift);
$response->body( $e->stringify );
}
else {
$e->throw();
Expand Down
20 changes: 12 additions & 8 deletions CommentPlugin/pub/System/CommentPlugin/comment.uncompressed.js
Expand Up @@ -88,24 +88,27 @@ This is an example of a simple AJAX comment submission.
if (typeof(StrikeOne) !== 'undefined')
StrikeOne.submit(form);
$.ajax({
url: form.action,
type: "POST",
data: $(form).serialize(),
url: form.action,
type: "POST",
data: $(form).serialize(),
beforeSend: function() {
$(form).find('input').attr("disabled", "disabled");
},
success: function(data, textStatus, jqXHR) {
success: function(data, textStatus, jqXHR) {
var position = jqXHR.getResponseHeader(
'X-Foswiki-Comment');
addComment(position, data, form);
$(form).find('input').removeAttr("disabled");
$("body").css("cursor", "default");
},
error: function(jqXHR, textStatus, errorThrown) {
alert("Error: " + errorThrown);
error: function(jqXHR, textStatus, errorThrown) {
if (jqXHR.responseText)
alert("Error: " + jqXHR.responseText);
else
alert("Error: " + errorThrown);
$(form).find('input').removeAttr("disabled");
$("body").css("cursor", "default");
},
},
complete: function(jqXHR) {
// Update the strikeone nonce
var nonce = jqXHR.getResponseHeader('X-Foswiki-Validation');
Expand All @@ -116,7 +119,8 @@ This is an example of a simple AJAX comment submission.
});
}
}
})
});
return false;
});
});
})(jQuery);

0 comments on commit 7bca1b4

Please sign in to comment.