1 $(document
).ready(function() {
2 $('#recaptcha_widget').show();
3 $('.submit').click(function() {
4 if ($('#comment_text').val() != '') {
5 var challenge
= Recaptcha
.get_challenge();
6 var response
= Recaptcha
.get_response();
7 var captcha_data
= { "challenge" : challenge
,
8 "response" : response
};
13 success: function(data
) {
14 if (data
.split('\n')[0] == 'true') {
15 var name
= $("#comment_name").val();
16 var email
= $("#comment_email").val();
17 var text
= $("#comment_text").val();
18 var comment_data
= { "captcha" : "passed",
24 // the url may need to be adjusted for
29 var new_post
= "<h3><a href='mailto:" + email
30 + "'>" + name
+ "</a></h3>"
32 $('#comments').prepend(new_post
);
34 console
.log('posted new comment');
38 var error
= "<span style='font-weight:bold;font-family:sans-serif;color:red;margin-top:15px;'>reCAPTCHA said you're not human</span>";
39 $('#comment').append(error
);
45 complete: function() {
50 var error
= "<span style='font-weight:bold;font-family:sans-serif;color:red;margin-top:15px;'>but you didn't write anything!<br></span>";
51 $('#submit').before(error
);