Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 322135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:54:36+00:00 2026-05-12T08:54:36+00:00

Below is the code so far that I am working on, It will be

  • 0

Below is the code so far that I am working on, It will be a comment system, the flow:

  1. User fills in comment form
  2. hit submit, AJAX call is made and
    POST to a php script

  3. script determines if user should
    enter a captcha form

  4. If they need a captcha form it sends
    that response back along with there
    sanitized message

  5. If they do not need captcha, it
    sanitizes the message and sends it
    back with a success response

  6. If there is an error it sends an
    error message back.

  7. If success we also add the message
    to the page

Ok my problems so far is that when I hit submit, it reloads the page instead of doing the ajax call, do you see any obvious reasons?

<script type="text/javascript">
$(document).ready(function () {
    $('#load').hide();
    //load facebox
     $('a[rel*=facebox]').facebox() 
});


// add comments
var messageArea = $('textarea#message');
$('input#submit-comment').click(function () {
    // Store vars
    var message = messageArea.hide().val();
    var dataString = 'message=' + message + '&u=1';

    //send comment to php
    $.ajax({
        type: "POST",
        url: "process.php",
        data: dataString,
        dataType: "json",
        success: function (data) {
            if (json.response == 'captcha') {
                //they are mass posting so we need to give them the captcha form
                // maybe we can open it in some kind of dialog like facebox
                // have to figure out how I can pass the comment and user data to the captcha script and then post it
                jQuery.facebox(function () {
                    jQuery.get('captchabox.php', function (data) {
                        jQuery.facebox('<textarea>' + data + '</textarea>')
                    })
                })
                alert('captcha');
            } else if (json.response == 'error') {
                // there was some sort of error so we will just show an error message in a DIV
                // just an alert for testing purposes
                alert('sorry there was an error');
            } else if (json.response == 'success') {
                alert('sucess');
                // success append the sanitized-comment to the page
                $('#comments').prepend(obj.comment);
            };
        }
    })
    return false;
});
</script>

<div id="container">
    <div id="comments">
<!-- comments loop will be here from mysql results -->
        <div class="comment">
            <div class="date">
                <span class="day-month"><?php echo $dayMonth; ?></span>
                <span class="year"><?php echo $year; ?></span>
            </div>
            <span class="content"><?php echo stripslashes($message);?> <span class="time"><?php echo $datediff; ?></span></span>
            <div class="clear"></div>
        </div>
<!-- end comment loop-->
    </div>
    <div id="submission">
        <form name="comment-submission">
            <textarea id="message" name="message"></textarea>
            <span class="limit">140</span>
            <input type="submit" id="submit-comment" value=" " />
        </form>
        <div class="clear"></div>
    </div>
</div>

UPDATE:

I have added in return false; just before the closing of the click function below the ajax call but it has made no change on the page, it still reloads the page on click, any help please

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T08:54:36+00:00Added an answer on May 12, 2026 at 8:54 am

    Add a return false; after your call of $.ajax(). This will prevent the default action for submit element.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 192k
  • Answers 192k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The article and the project are from the same person.… May 12, 2026 at 6:18 pm
  • Editorial Team
    Editorial Team added an answer The way you describe in your penultimate paragraph is the… May 12, 2026 at 6:18 pm
  • Editorial Team
    Editorial Team added an answer I created a Service Contract class implementing 2 Interfaces like… May 12, 2026 at 6:18 pm

Related Questions

I am working on a small widget for BlogEngine.Net. My widget is going to
I am working on a comment system and design is my weak area, So
I'm working through Real World Haskell , and at the moment doing the exercises
I have been working all night and yesterday on this header section in css,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.