0

I want to make friend request system. When I click the "Add friend" button, this button hide and sent button show.

$(document).ready(function() {
  $(".add-button").click(function(){
    $.post("friend-list.php", function(data, status){
      $(this).hide();
      $(this).next().show();
    });
  });
});

Some screenshot

list of friend list

(this) selector does not have any effect. How can I do this?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • If the `button` elements are inside a `form` element your AJAX request will be cancelled and the form will be submit as normal. If so you need to hook to the `submit` event of the form and call `preventDefault()` on the event. – Rory McCrossan Apr 05 '17 at 14:56
  • ...or make the buttons just buttons: ` – T.J. Crowder Apr 05 '17 at 14:58

0 Answers0