Message always appears in first row?
<p>I have a delete function within a function where if the user clicks on the "Delete" button, it displays a message stating that a file has been deleted. The code which does this is below:</p>

<pre><code>$("#imagemsg").html(data);
</code></pre>

<p>But the problem is that let's say that I have 4 table rows and I delete a file in the 3rd row, the message should be displayed in the 3rd row only but instead it is displayed in the first row. Another example is that let's say that I have 8 table rows and I delete a file in the 6th row, the message should be displayed in the 6th row only but instead it is displayed in the first row.</p>

<p>Why is the message that is suppose to appear after a file is deleted is always displayed in the first row and not within the row the file has been deleted from?</p>

<p>Below is full code:</p>

<pre><code> var counter = 0;
      counter++;

function stopImageUpload(success, imagefilename){

      var result = '';

      if (success == 1){
         result = '&lt;span id="imagemsg'+counter+'"&gt;The file was uploaded successfully!&lt;/span&gt;&lt;br/&gt;&lt;br/&gt;';      
         $('.listImage').eq(window.lastUploadImageIndex).append('&lt;div&gt;' + htmlEncode(imagefilename) + '&lt;button type="button" class="deletefileimage" image_file_name="' + imagefilename + '"&gt;Remove&lt;/button&gt;&lt;br/&gt;&lt;hr/&gt;&lt;/div&gt;'); 
      }
      else {
         result = '&lt;span id="imageemsg"&gt;There was an error during file upload!&lt;/span&gt;&lt;br/&gt;&lt;br/&gt;';
      }


      $(".deletefileimage").on("click", function(event) {

         var image_file_name = $(this).attr('image_file_name');

    jQuery.ajax("deleteimage.php?imagefilename=" + image_file_name)
      .done(function(data) {
        $("#imagemsg" + counter).html(data);
       });

       $(this).parent().remove();

    });

      return true;   
}
</code></pre>

<p>Below is the deleteimage.php script where the delete message is retrieved from:</p>

<pre><code>&lt;?php
  $image_file_name = $_GET["imagefilename"];

    echo "$image_file_name was Deleted";
    unlink("ImagesFilesFolder/$image_file_name");


?&gt;
</code></pre>
