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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:27:08+00:00 2026-05-20T18:27:08+00:00

I have a jquery function to delete a file from a list and then

  • 0

I have a jquery function to delete a file from a list and then reload the list via AJAX.

It works perfectly…but only once.

        $(".delbutton").click(function(){
        var filename = $(this).attr("id");
        var info = 'pid=<?php echo $_GET["pid"]; ?>&f=' + filename;
            $.ajax({
                type: "POST",
                url: "deleteupload.php",
                data: info,
                success: function(){
                    $('#filelist').load("files.php?pid=<?php echo $_GET["pid"]; ?>");
                }
            });
    });

});

The HTML is

<div id="filelist"> 
     <img src='/images/cross.png' alt='delete' class='delbutton' id='OUCH.gif'>&nbsp;OUCH.gif<br>

<img src='/images/cross.png' alt='delete' class='delbutton' id='xmas_tree.png'>&nbsp;xmas_tree.png<br>
    </div> 

Another jquery function on the page continues to work when this one doesn’t so it isn’t jquery that is broken.

Someone is going to see the problem, I can’t.

  • 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-20T18:27:09+00:00Added an answer on May 20, 2026 at 6:27 pm

    The trouble is that you are binding to elements that match .delbutton, but you then replace them with the $('#filelist').load call. The standard binding functions such as click bind to the element, not to the selector.

    The easy way around this is to use either live or delegate. I prefer the delegate syntax:

    $('#filelist').delegate(".delbutton", 'click', function(){
         // your code here
    });
    

    NB There are probably better places to put a filename than in the id attribute… I’d suggest using a data-url attribute instead. (See data.)

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

Sidebar

Related Questions

I have some jQuery code. I have called an Ajax function file, file.php, that
Background: My webpage loads entries from an XML file via AJAX/jQuery and displays them
I have this jQuery which works fine $(li[id^='shop_id']).click( function () { alert(I clicked on
I have a form I am submitting using jQuery's ajaxSubmit function from the Forms
I have created a function outside of $(document).ready() , but am still using jQuery
I use jquery ajax to get data from the PHP file. data = <option>Peter</option><option>Maria</option>
I'am building simple Ajax application (via jquery). I have strange issue. I found where
I have a form submit with an AJAX post. It works fine. But when
I have an ajax call bound to a link via jQuery, and I want
I'm struggling to find the right terminology here, but if you have jQuery object...

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.