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 6597905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:16:10+00:00 2026-05-25T18:16:10+00:00

I have set up an submit box using ajax function and when success, I

  • 0

I have set up an submit box using ajax function and when success, I have the function .append()

The problem is that it will append consecutively when I try to submit something. For example: if I submit a comment the first time, it appends correctly, then if I submit another comment right after (without refreshing page), it will append twice, then if I submit another comment after that, it will append three times, so on and so forth. How do I prevent this from happening?

    var id = $(this).attr('id');
    $('#comments_'+id).keydown(function(e){
        if(e.keyCode == 13)
        {
            e.preventDefault();
            var comment = $(id).val();
            var comment = 'comment='+comment;

            $.ajax({
            type: "POST",
            url: "edit.php",
            data: comment,
            cache: false,
            success: function(data)
            {
                $('#commentSelect'+id).append(data);
            }

        }); 
                return false;

        }
    });

I set up, so I can submit on enter

Thank you for your time!

  • 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-25T18:16:11+00:00Added an answer on May 25, 2026 at 6:16 pm

    Without knowing a few more details, I would guess you are loading this javascript after each ajax request. Every time it is run it rebinds the event. You either need to load it only once per page load, or change

    $('#comments_'+id).keydown(function(e){
    

    to

    $('#comments_'+id).unbind('keydown').keydown(function(e){
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I try to read my cookie that I have set something does not
I currently have my code set to disable the submit button when the field
I have set up a version control system using TortoiseSVN at my home to
I have set up a Django application that uses images. I think I have
I'm using VS2010,C#, I have a table that its data should be created dynamically
The purpose is to have a checkbox, that if clicked, will send via post
I have web search form, When i submit my search in the search box,
I have a set of radio buttons that are for certain products. I am
I have a Table that is generated using a SQL Database And put into
I have a view model with a from that includes a set of checkboxes.

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.