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

  • SEARCH
  • Home
  • 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 8000933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:57:05+00:00 2026-06-04T15:57:05+00:00

I wrote a webpage where a user can enter a log entry that is

  • 0

I wrote a webpage where a user can enter a log entry that is stored on a database and then retrieved and printed on the page using ajax. I am still quite new to ajax and was wondering if somebody could please explain to me what does return false; do at the end of my code? and is it even necessary?

If I put the second ajax code after the return false the code does not work! can you please explain to me why?

//handles submitting the form without reloading page 
$('#FormSubmit').submit(function(e) {
    //stores the input of today's data
    var log_entry = $("#LogEntry").val();
    // prevent the form from submitting normally
    e.preventDefault();

    $.ajax({
        type: 'POST',
        url: 'behind_curtains.php',
        data: {
            logentry: log_entry
        },
        success: function() {
            alert(log_entry);
            //clears textbox after submission
            $('#LogEntry').val("");
            //presents successs text and then fades it out
            $("#entered-log-success").html("Your Entry has been entered.");
            $("#entered-log-success").show().fadeOut(3000);
        }
    });
    //prints new log entries on page upon submittion
    $.ajax({
        type: 'POST',
        url: '/wp-content/themes/childOfFanwood/traininglog_behind_curtains.php',
        data: {
            log_entries_loop: "true"
        },
        success: function(data) {
            alert(data);
            $("#log-entry-container").html("");
            $("#log-entry-container").html(data);
        }
    });
    return false;
});
​
  • 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-06-04T15:57:06+00:00Added an answer on June 4, 2026 at 3:57 pm

    What I’ll write here is true for jQuery events,
    For vanilla javascript events read @T.J. Crowder comment at the bottom of the answer


    return false inside a callback prevents the default behaviour. For example, in a submit event, it doesn’t submit the form.

    return false also stops bubbling, so the parents of the element won’t know the event occurred.

    return false is equivalent to event.preventDefault() + event.stopPropagation()

    And of course, all code that exists after the return xxx line won’t be executed. (as with all programming languages I know)

    Maybe you find this helpful:
    Stop event bubbling – increases performance?


    A “real” demo to explain the difference between return false and event.preventDefault():

    Markup:

    <div id="theDiv">
        <form id="theForm" >
            <input type="submit" value="submit"/> 
        </form>
    </div>​
    

    JavaScript:

    $('#theDiv').submit(function() {
        alert('DIV!');
    });
    $('#theForm').submit(function(e) {
        alert('FORM!');
        e.preventDefault();
    });​
    

    Now… when the user submit the form, the first handler is the form submit, which preventDefault() -> the form won’t be submitted, but the event bubbles to the div, triggering it’s submit handler.

    Live DEMO

    Now, if the form submit’s handler would cancel the bubbling with return false:

    $('#theDiv').submit(function() {
        alert('DIV!');
    });
    $('#theForm').submit(function(event) {
        alert('FORM!');
        return false;   
        // Or:
        event.preventDefault(); 
        event.stopPropagation();
    });​
    

    The div wouldn’t even know there was a form submission.

    Live DEMO


    What does return false do in vanilla javascript events

    return false from a DOM2 handler (addEventListener) does nothing at all (neither prevents the default nor stops bubbling; from a Microsoft DOM2-ish handler (attachEvent), it prevents the default but not bubbling; from a DOM0 handler (onclick="return ..."), it prevents the default (provided you include the return in the attribute) but not bubbling; from a jQuery event handler, it does both, because that’s a jQuery thing. Details and live tests here – T.J. Crowder

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

Sidebar

Related Questions

I am developing a webpage in that the user can download their Resume for
I have a sql database that stores some documents. A user can sign into
Summary: web page has a few fields to allow the user to enter payments.
I have web page with some really large tables that I'm filtering using some
I am just trying to write a small web page that can parse some
On my ASP.Net page in C#, the user is able to enter an URL
I wrote a simple webpage as follows: <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN
I wrote some bookmarklets to automate some tasks on a webpage. I'd like to
I'm trying to write a web page in .NET, using C# and NHibernate 2.1.
I wrote a small internal web app using (a subset of) pylons . As

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.