Skip to content

Instantly share code, notes, and snippets.

@hrumhrumble
Last active August 29, 2015 14:07
Show Gist options
  • Save hrumhrumble/bf87cf7300b802a76772 to your computer and use it in GitHub Desktop.
Save hrumhrumble/bf87cf7300b802a76772 to your computer and use it in GitHub Desktop.
//DEMO - http://pavelshcheglov.com/portfolio/comment-box/
$(function(){
$(".comments.add").on("click", "button", function(e){
e.preventDefault();
$("button").prop("disabled", true);
$("textarea").prop("disabled", true);
$(".loader").show();
setTimeout(function() {
$.ajax({
url: "_php/action_insert.php",
type: "POST",
cache: false,
data: {messg: $(".user-text-add").val()},
dataType: "html",
complete: function(result){
console.log(result);
$(".comments-box").append(result.responseText);
$("button").prop("disabled", false);
$("textarea").prop("disabled", false);
$(".loader").hide();
$("textarea").val("");
$(".comment-button").text($(".comments-box").children(".comment").length);
}
});
}, 500);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment