Now loads new comment after posting
authorDylan Lloyd <dylan@psu.edu>
Thu, 10 Mar 2011 08:25:31 +0000 (03:25 -0500)
committerDylan Lloyd <dylan@psu.edu>
Thu, 10 Mar 2011 08:25:31 +0000 (03:25 -0500)
includes/ajax.js
index.php

index 50541dc..afc73e8 100644 (file)
@@ -25,6 +25,11 @@ $(document).ready(function() {
                         url: "verify",
                         data: comment_data,
                         success: function() {
+                          var new_post = "<h3><a href='mailto:" + email
+                                          + "'>" + name + "</a></h3>"
+                                                          + text + "<br><br>";
+                          $('#comments').prepend(new_post);
+                          $('#comment').hide();
                           console.log('posted new comment');
                         }
                   });
index 8f8baae..ef5eddf 100644 (file)
--- a/index.php
+++ b/index.php
@@ -456,7 +456,6 @@ END_OF_COMMENT;
     $publickey = $this->recaptcha_publickey;
     echo <<<END_CAPTCHA_STYLE
 <script type="text/javascript">
-function showRecaptcha() {
 Recaptcha.create("$publickey",
    "recaptcha_div", 
    {
@@ -464,16 +463,14 @@ Recaptcha.create("$publickey",
      custom_theme_widget: 'recaptcha_widget',
      callback: Recaptcha.focus_response_field
    });
-}
 </script>
 END_CAPTCHA_STYLE;
     require_once('includes/recaptchalib.php');
        // Trailing slash is necessary for reloads to work
-    $url = $this->url . "verify";
+    $url = $this->url . "verify/";
        echo "<form id=\"comment_form\"  method=\"post\" action=\"$url\">";
-       echo  <<<END_OF_FORM
+       echo <<<END_OF_FORM
 <div id="comment">
-<h3><a onclick="showRecaptcha();">comment?</a></h3>
 
 <div id="recaptcha_div">
 <br>
@@ -493,6 +490,9 @@ END_CAPTCHA_STYLE;
 <div style="float:right;position:relative;width:100px;"><div id="recaptcha_image"></div></div>
 <br><br><br><br>
 </div>
+END_OF_FORM;
+    echo recaptcha_get_html($this->recaptcha_publickey); 
+    echo <<<END_OF_FORM
 </div>
 
 <input class="submit" type="submit" value="comment">