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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:40:08+00:00 2026-06-12T11:40:08+00:00

So I am executing a $.post() to get some html code returned from a

  • 0

So I am executing a $.post() to get some html code returned from a php script which accesses an SQLite database

I need to attach a click event to an edit button that shows when the page loads the new html, so I attach the click event after the .empty().html() then if the user edits the record by submitting the data it does another $.post() to reresh the screen and show the new data, so I attach the click event handler again, because if I don’t the edit buttons on the page don’t work anymore because they weren’t there when the `.click()’ was attached the first time

BUT when I do this and edit multiple records it runs multiple times (I alert the record ID each time it does a $.post() and it does it the same amount of times as edits I have clicked, I have seen posts about how .live() can cause this issue and people suggest binding click which is what I am doing, so I don’t see what’s happening…here is the code

$(".edit").click(function(e){
    e.preventDefault();
    $realTipID=this.id;
    $.post("ajax.php",{action:'getTip',tipID:$realTipID},function(data){
            $("#editTip_div").css("display","block");
            $("#editText").empty().val(unEscapeSpecialChars(data));//puts the data that is currently in the DB into a textarea to be editted
            $("#edit_tip").click(function(e){
            $.post("ajax.php",{action:'editTip',tipID:$realTipID,editText:escapeSpecialChars($("#editText").val())},function(data){

            if (data=="1")  {//check tosee that the update of the SQL table worked
                e.preventDefault();//tried this because someone suggested it in another StackOverflow post
                $(".edit").unbind('click');//and this
                $realTipID='';
                $("#editText").val('');
                $("#editTip_div").css("display","none");
                $('.result[id|='+$issueID+']').click();//refreshes the <div> with the content, includes this $(".edit").click() event 
            if (data=="0")  {//or failed
                alert("record not written, could be that there are quotes in the text, please remove, quotes, apostraphes, and ticks (`) as they will cause the line to fail"); 
            }

                                                        });
        });
        $("#cancel_edit").click(function()  {
            $("#editText").val('');
            $("#editTip_div").css("display","none");
                                                                });
        });

});
  • 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-12T11:40:10+00:00Added an answer on June 12, 2026 at 11:40 am

    Sounds like you’re setting multiple event handlers on the same element. Does this help?
    edit: sorry, that should have been:

    $(".edit").unbind().click(function(e){
    

    Edited from:

    $("#cancel_edit").unbind().click(function() 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a project in which I need to get some data from
Let's say I have an index.php where I use some form of http get/post
I'm javascript newbie...please bear with me. Modified some jQuery animation code from w3c tutorial.
Trying to print out some html forms but I get a parsing syntax error.
So I'm trying to get some tutorial code working, and I'm stuck. I have
I found some PHP code on the 'net that supposedly will help me send
this is a continuation of the previous post. I need to change some parameters(strings)
Have some Perl code which is using the DBI module - (the code is
I need to POST (HTTP method) some info to an external URL when a
Executing in method checkUnique the line $res=$select->fetchArray(); in the following class I get an

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.