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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:57:02+00:00 2026-05-28T13:57:02+00:00

All, I’ve got some links that get displayed and someone can click the link

  • 0

All,
I’ve got some links that get displayed and someone can click the link if a person likes it and then I basically assign it to another div with a remove link so it can be removed. Here is the code for the .post

jQuery.post("save_song.php", { song_id: song_id, love_like_hate: "love" },
       function(response) {
         if(response.responseText1=="too_many"){
                alert(response.responseText2);
            }else if(response.responseText1=="already_selected"){
                alert(response.responseText2);
            }else{
                alert(response.responseText2);
                jQuery("#div_song_id_"+song_id).html(response.responseText1);
                jQuery("#love_it").append(response.responseText2);
                jQuery("#current_count_love").html(response.responseText3);
                if(response.responseText4=="remove_initial"){
                    jQuery("#love_none").hide();
                }
            }
    }, "json");

Here is the save_song.php page that sends back the page:

echo json_encode(array(
            'responseText1' => 'Youve added '.$artist_name.' - '.$track_name.' to your '.$love_like_hate.' list!',
            'responseText2' => '<div id="div_added_song_id_'.$song_id.'" style="padding:0 0 0 10px; "><span style="display:inline-block; width:200px;">'.$artist_name.'</span><span style="display:inline-block; width:400px;">'.$track_name.'</span><span style="display:inline-block; width:100px;">'.$track_time.'</span><span style="display:inline-block; width:100px;"><a href="#" class="remove_song" id="delete_'.$song_id.'">Remove</a></span></div>',
            'responseText3' => $resultrowschecktotal
        ));

My issue is that when the response.responseText2 is appended to my div the jquery for the .remove_song doesn’t work and it basically just uses the link and tries to do #. Here is the code for the remove_song:

jQuery(".remove_song").click(function(){
    event.preventDefault();
    song_id = jQuery(this).attr("id");
    song_id = song_id.split("_");
    song_id = song_id[1];
    var answer = confirm("Do you want to remove this song?")
    if (answer){
        jQuery.post("delete_song.php", { song_id: song_id },
            function(response) {
                jQuery("#div_added_song_id_"+song_id).hide();
                jQuery("#current_count_"+response.responseText2).html(response.responseText1);
            }, "json");
    }
});

How can I still utilize this for newly appended links since they aren’t loaded when the DOM is finished?

  • 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-28T13:57:02+00:00Added an answer on May 28, 2026 at 1:57 pm

    Your latest anchor element doesnt bind anything, so it wont do anything when clicking, try jquery live
    like this:

    jQuery(".remove_song").live('click', function(){
        event.preventDefault();
        song_id = jQuery(this).attr("id");
        song_id = song_id.split("_");
        song_id = song_id[1];
        var answer = confirm("Do you want to remove this song?")
        if (answer){
          jQuery.post("delete_song.php", { song_id: song_id },
            function(response) {
                jQuery("#div_added_song_id_"+song_id).hide();
                jQuery("#current_count_"+response.responseText2).html(response.responseText1);
            }, "json");
        }
    });
    

    for jquery 1.7+ use

    jQuery(document).on('click','.remove_song',function(){
        event.preventDefault();
        song_id = jQuery(this).attr("id");
        song_id = song_id.split("_");
        song_id = song_id[1];
        var answer = confirm("Do you want to remove this song?")
        if (answer){
          jQuery.post("delete_song.php", { song_id: song_id },
            function(response) {
                jQuery("#div_added_song_id_"+song_id).hide();
                jQuery("#current_count_"+response.responseText2).html(response.responseText1);
            }, "json");
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All, I have some script tags that are not working in Wordpress. If I
All my searches returned nothing and I find it odd that there aren't any
All I want is a pragmatic random number generator in C# so I can
All I want is to get the website URL. Not the URL as taken
All the guys probably will recommend that I read the follow previously question in
All programs that I develop utilize the default Windows Design template: Besides from changing
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
All, I'm using wordpress with this and for some reason the eventDrop stopped working.
All I need is to create a file that contains a file names' list
All right, so I've got an applet I'm trying to embed into an HTML

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.