Skip to content

Instantly share code, notes, and snippets.

@ksurya
Created June 26, 2013 23:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ksurya/5872853 to your computer and use it in GitHub Desktop.
Save ksurya/5872853 to your computer and use it in GitHub Desktop.
ajaxforms
$(document).ready(function() {
var formId = '#spc-comment-flag-form';
var formRespId = '#spc-comment-flag-response';
var options = {
type: $(formId).attr('method'),
url: $(formId).attr('action'),
success: function(data) {
if (data.error){
$(formRespId).html(data.msg);
}
else {
var msg = '<b>Flagging successful.</b> Thanks for taking the time to improve the quality of discussion on our site.';
$(formRespId).html(msg);
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
var msg = '<b>The comment was not flagged.</b> Sorry for the inconvenience <br> Please try again! ';
console.log(errorThrown);
console.log(textStatus);
$(formRespId).html(msg);
},
clearForm: true,
resetForm: true,
};
$(formId).ajaxForm(options);
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment