We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Ajax Comment Form Not Returning Success Template Content

Development and Programming

KMGDEV's avatar
KMGDEV
121 posts
13 years ago
KMGDEV's avatar KMGDEV

UPDATE: I moved this question over to Stack Overflow.

So I have a basic comment form hooked up with the jQuery Form plugin (only members can post so no name/email fields):

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">

  {!-- Script tags Linking to jQuery 1.7.2 and the jQuery Form plugin --}
  [removed][removed]
  [removed][removed]
  [removed]
    $(document).ready(function(){

      function ajaxReturn(data) {
        var messageContainer = $('.alert-box');
        var messageBody = $(data);
        messageContainer.html(messageBody);
      }// ajaxReturn(data)

      $('.member-review').ajaxForm({
        success: ajaxReturn
      });
    });
  [removed]

</head>
<body>
    {exp:channel:entries
      channel='products'
      limit='1'
      disable='categories|member_data|pagination'
    }
      {exp:comment:form
        channel='products'
        form_class='member-review'
        return='notifications/success'
      }
        <div class="alert-box">
          {!-- Ajax Form Errors --}
        </div><!--.alert-box-->

        <label for="comment">Tell others what you think</label>
        <textarea name="comment" rows="8" class="required" id="comment"></textarea>

        <input type="submit" value="Submit">
      {/exp:comment:form}
    {/exp:channel:entries}
</body>
</html>

And, for the purposes of this demo, my success template could not be more simple:

Sumission Successful!

Unfortunately when I submit a completed form, no data is returned. If I add

console.log〈$(data〉);

to the ajaxReturn function, I get an empty string. The comment is successfully submitted to the database, it’s just the return template that doesn’t seem to make it.

Really not sure why this is happening. It returns error messages correctly, just not the success template.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.