X-Git-Url: https://disinclined.org/git/?a=blobdiff_plain;f=includes%2Fajax.js;h=bc51be3ccd4163b40bdab49ef2d331de886a20cd;hb=c30849c73508b5a0168b6559b9935115186a20c7;hp=50541dc89aa70b782593de2d6759e876da2eeb06;hpb=409920abbe043085f168136e85344a5d28542163;p=dylansserver.git diff --git a/includes/ajax.js b/includes/ajax.js index 50541dc..bc51be3 100644 --- a/includes/ajax.js +++ b/includes/ajax.js @@ -1,4 +1,5 @@ $(document).ready(function() { + $('#recaptcha_widget').show(); $('.submit').click(function() { if ($('#comment_text').val() != '') { var challenge = Recaptcha.get_challenge(); @@ -14,6 +15,7 @@ $(document).ready(function() { var name = $("#comment_name").val(); var email = $("#comment_email").val(); var text = $("#comment_text").val(); + if (name == '') { name = "anon" } var comment_data = { "captcha" : "passed", "name" : name, "email" : email, @@ -25,11 +27,17 @@ $(document).ready(function() { url: "verify", data: comment_data, success: function() { + var new_post = "

" + name + "

" + + text + "

"; + $('#comments').prepend(new_post); + $('#comment').hide(); console.log('posted new comment'); } }); } else { - console.log('reCAPTCHA said you\'re not human.'); + var error = "reCAPTCHA said you're not human"; + $('#comment').append(error); } }, error: function() { @@ -40,7 +48,8 @@ $(document).ready(function() { } }); } else { - console.log('but you didn\'t write anything!'); + var error = "but you didn't write anything!
"; + $('#submit').before(error); } return false; });