Created
June 26, 2013 23:56
-
-
Save ksurya/5872853 to your computer and use it in GitHub Desktop.
ajaxforms
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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